refs : Object[]5

Array of configs to build up references to views on page. For example:

Ext.define("MyApp.controller.Foo",{
extend:"Ext.app.Controller", refs:[{ref:'list',
selector:'grid'}],});

这将会产生一个this.getList()方法,该方法会通过Ext.ComponentQuery去页面中获取组件为grid的组件

The following fields can be used in ref definition:

  • ref - name of the reference.
  • selector - Ext.ComponentQuery selector to access the component.
  • autoCreate - 如果在页面中找不到该组件,是否自动创建
  • forceCreate - 强制在每次访问该组件的时候都自动创建一次
  • xtype - 要创建的组件xtype类型. If you don't provide xtype, an Ext.Component instance will be created.

Ext.ComponentQuery

1.#myPanel 根据id获取

2.panel#myPanel xtype类型为panel,并且id为myPanel的,缩小查找范围

3.CSS选择器

  • E F All descendant Components of E that match F
  • E > F All direct children Components of E that match F
  • E ^ F All parent Components of E that match F
window[title="Input form"] textfield[name=login]^ form > button[action=submit]
以为:title为“Input form”的window,里面name=login的文本框,所属的form下面的action=submit的按钮

4.属性

  component[autoScroll],组件中含有autoScroll=true的
  panel[title="Test"],组件xtype为panel并且title为test的
  component[?autoScroll],组件中含有autoScroll,无论其值是多少
5.模糊定位
  

Ext.ComponentQuery.query('panel[cls=my-cls]');
//可以找到
Ext.create('Ext.window.Window', {
cls: 'my-cls'
});
//但找不到
Ext.create('Ext.panel.Panel', {
cls: 'foo-cls my-cls bar-cls'
});
/***********************************/
Ext.ComponentQuery.query('panel[cls~=my-cls]');
//可以同时找到上面两个组件
/***********************************/
Ext.ComponentQuery.query('panel[title^=Sales]');
//Title以Sales开头的Panel
/***********************************/
Ext.ComponentQuery.query('field[fieldLabel$=name]');
//fieldlabel以name结尾的
Ext.create('Ext.form.field.Text', {
fieldLabel: 'Enter your name'
});
/***********************************/

6.条件组合查找

//and
Ext.ComponentQuery.query('panel[cls~=my-cls][floating=true][title$="sales data"]');
//or
Ext.ComponentQuery.query('field[fieldLabel^=User], field[fieldLabel*=password]');

7.伪类(preudo classes),筛选结果

  • not Negates a selector.
  • first Filters out all except the first matching item for a selector.
  • last Filters out all except the last matching item for a selector.
  • focusable Filters out all except Components which are currently able to recieve focus.
  • nth-child Filters Components by ordinal position in the selection.
// Select first direct child button in any panel
Ext.ComponentQuery.query('panel > button:first'); // Select last field in Profile form
Ext.ComponentQuery.query('form[title=Profile] field:last'); // Find first focusable Component in a panel and focus it
panel.down(':focusable').focus(); // Select any field that is not hidden in a form
form.query('field:not(hiddenfield)');

8.例子

// retrieve all Ext.Panels in the document by xtype
var panelsArray = Ext.ComponentQuery.query('panel'); // retrieve all Ext.Panels within the container with an id myCt
var panelsWithinmyCt = Ext.ComponentQuery.query('#myCt panel'); // retrieve all direct children which are Ext.Panels within myCt
var directChildPanel = Ext.ComponentQuery.query('#myCt > panel'); // retrieve all grids or trees
var gridsAndTrees = Ext.ComponentQuery.query('gridpanel, treepanel'); // Focus first Component
myFormPanel.child(':focusable').focus(); // Retrieve every odd text field in a form
myFormPanel.query('textfield:nth-child(odd)'); // Retrieve every even field in a form, excluding hidden fields
myFormPanel.query('field:not(hiddenfield):nth-child(even)');
 
 
 

Extjs4.x (MVC)Controller中refs以及Ext.ComponentQuery解析的更多相关文章

  1. Extjs4 MVC Controlller中refs使用

    前面几篇写了一下mvc的整体使用方法,今天写一下controller中refs的试用,refs的作用类似于我们告诉controller我们的一个元素的别名,既alias,那么controller就会为 ...

  2. Spring MVC Controller中解析GET方式的中文参数会乱码的问题(tomcat如何解码)

    Spring MVC Controller中解析GET方式的中文参数会乱码的问题 问题描述 在工作上使用突然出现从get获取中文参数乱码(新装机器,tomcat重新下载和配置),查了半天终于找到解决办 ...

  3. spring mvc controller中获取request head内容

    spring mvc controller中获取request head内容: @RequestMapping("/{mlid}/{ptn}/{name}") public Str ...

  4. Spring MVC Controller中GET方式传过来的中文参数会乱码的问题

    Spring MVC controller 这样写法通常意味着访问该请求,GET和POST请求都行,可是经常会遇到,如果碰到参数是中文的,post请求可以,get请求过来就是乱码.如果强行对参数进行了 ...

  5. spring mvc Controller中使用@Value无法获取属性值

    在使用spring mvc时,实际上是两个spring容器: 1,dispatcher-servlet.xml 是一个,我们的controller就在这里,所以这个里面也需要注入属性文件 org.sp ...

  6. spring mvc controller中的异常封装

    http://abc08010051.iteye.com/blog/2031992 一直以来都在用spring mvc做mvc框架,我使用的不是基于注解的,还是使用的基于xml的,在controlle ...

  7. 二、ASP.NET MVC Controller 控制器(一:深入解析控制器运行原理)

    阅读目录: 1.开篇介绍 2.ASP.NETMVC Controller 控制器的入口(Controller的执行流程) 3.ASP.NETMVC Controller 控制器的入口(Controll ...

  8. NET/ASP.NET MVC Controller 控制器(一:深入解析控制器运行原理)

    阅读目录: 1.开篇介绍 2.ASP.NETMVC Controller 控制器的入口(Controller的执行流程) 3.ASP.NETMVC Controller 控制器的入口(Controll ...

  9. 在ASP.NET MVC 框架中调用 html文件及解析get请求中的参数值

    在ASP.NET MVC 框架中调用 html文件: public ActionResult Index() { using (StreamReader sr = new StreamReader(P ...

随机推荐

  1. 使用 NodeJS + Express 從 GET/POST Request 取值 -摘自网络

    過去無論哪一種網站應用程式的開發語言,初學者教學中第一次會提到的起手式,八九不離十就是 GET/POST Request 的取值.但是,在 Node.js + Express 的世界中,彷彿人人是高手 ...

  2. Atitit js canvas的图像处理类库attilax总结与事业

    Atitit js canvas的图像处理类库attilax总结与事业 1.1. 脸部识别JavaScript类库Tracking.js1 1.2. AlloyImage特性1 1.3. CamanJ ...

  3. [svc]NFS存储企业场景及nfs最佳实战探究

    办公网络里人一般系统用共享,尤其是财务, 他们喜欢直接点开编辑. 而不喜欢ftp nfs在网站架构中的用途 注: 如果pv量少,则放在一台机器上速度更快,如果几千万pv,则存储分布式部署. 网站架构中 ...

  4. Win7下使用无线网卡共享上网的4种方式

    我尝试了第一种直接上网了     一.Win7自带无线承载网络功能 1.查看网卡是否支持承载网络功能运行“命令提示符”   输入命令:netsh wlan show drivers图中红框“支持的承载 ...

  5. vue-cli项目配置图解

    配置vue项目机构步骤1.搭建环境:node.npm2.安装vue脚手架工具:npm install -g vue-cli3.初始化项目:vue init webpack vuedemo(“vuede ...

  6. 从头认识java-15.7 Map(5)-介绍HashMap的工作原理-Key变了,能不能get出原来的value?(偶尔作为面试题)

    这一章节我们讨论一个比較特殊的情况Key变了,能不能get出原来的value? 答案是:有时能够,有时不能够 1.能够的情况: package com.ray.ch14; import java.ut ...

  7. Spring Bean 的加载顺序

    一,单一Bean 装载 1. 实例化; 2. 设置属性值; 3. 如果实现了BeanNameAware接口,调用setBeanName设置Bean的ID或者Name; 4. 如果实现BeanFacto ...

  8. Linux 移动或重命名文件/目录-mv 的10个实用例子

    本文导航 -初识 mv 命令03% -1.移动文件08% -2.移动多个文件15% -3.移动目录23% -4.重命名文件或目录27% -5. 重命名目录35% -6. 打印移动信息39% -7. 使 ...

  9. git命令(9): 常见问题cover

    转载地址: https://blog.csdn.net/kkkkkxiaofei/article/details/41483039 情景1:多人协作之如何建立本地分支? 假若你已经clone了别人的仓 ...

  10. [转] lua 获取本地当月天数

    亲测,无误. 原文传送门:lua 获取本地当月天数 开发中有用到,记录一下. local year,month = os.date("%Y", os.time()), os.dat ...