Extjs4.x (MVC)Controller中refs以及Ext.ComponentQuery解析
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 FAll descendant Components of E that match FE > FAll direct children Components of E that match FE ^ FAll 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.属性
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),筛选结果
notNegates a selector.firstFilters out all except the first matching item for a selector.lastFilters out all except the last matching item for a selector.focusableFilters out all except Components which are currently able to recieve focus.nth-childFilters 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解析的更多相关文章
- Extjs4 MVC Controlller中refs使用
前面几篇写了一下mvc的整体使用方法,今天写一下controller中refs的试用,refs的作用类似于我们告诉controller我们的一个元素的别名,既alias,那么controller就会为 ...
- Spring MVC Controller中解析GET方式的中文参数会乱码的问题(tomcat如何解码)
Spring MVC Controller中解析GET方式的中文参数会乱码的问题 问题描述 在工作上使用突然出现从get获取中文参数乱码(新装机器,tomcat重新下载和配置),查了半天终于找到解决办 ...
- spring mvc controller中获取request head内容
spring mvc controller中获取request head内容: @RequestMapping("/{mlid}/{ptn}/{name}") public Str ...
- Spring MVC Controller中GET方式传过来的中文参数会乱码的问题
Spring MVC controller 这样写法通常意味着访问该请求,GET和POST请求都行,可是经常会遇到,如果碰到参数是中文的,post请求可以,get请求过来就是乱码.如果强行对参数进行了 ...
- spring mvc Controller中使用@Value无法获取属性值
在使用spring mvc时,实际上是两个spring容器: 1,dispatcher-servlet.xml 是一个,我们的controller就在这里,所以这个里面也需要注入属性文件 org.sp ...
- spring mvc controller中的异常封装
http://abc08010051.iteye.com/blog/2031992 一直以来都在用spring mvc做mvc框架,我使用的不是基于注解的,还是使用的基于xml的,在controlle ...
- 二、ASP.NET MVC Controller 控制器(一:深入解析控制器运行原理)
阅读目录: 1.开篇介绍 2.ASP.NETMVC Controller 控制器的入口(Controller的执行流程) 3.ASP.NETMVC Controller 控制器的入口(Controll ...
- NET/ASP.NET MVC Controller 控制器(一:深入解析控制器运行原理)
阅读目录: 1.开篇介绍 2.ASP.NETMVC Controller 控制器的入口(Controller的执行流程) 3.ASP.NETMVC Controller 控制器的入口(Controll ...
- 在ASP.NET MVC 框架中调用 html文件及解析get请求中的参数值
在ASP.NET MVC 框架中调用 html文件: public ActionResult Index() { using (StreamReader sr = new StreamReader(P ...
随机推荐
- []如何在Windows 10中更改文件夹背景颜色
ini文件.我们甚至可以使用相同的技术将图片设置为文件夹背景. 已有工具可以更改Windows 7中Windows资源管理器背景的颜色,并将图像设置为Windows 7中的文件夹背景,但这些工具与Wi ...
- [转]同一个tomcat不同项目的session共享问题
问题描述: session常常用来存储一些公共信息供不同页面访问,比如用户登录信息.访问同一个tomcat下的不同项目所创建的session是不一样的.自然地面临了如何共享session的问题. 解决 ...
- javaScript的变量
1.声明 用 var 或 let 声明的未赋初值的变量,值会被设定为undefined(译注:即未定义值,本身也是一个值) 试图访问一个未初始化的变量会导致一个 ReferenceError 异常被抛 ...
- 中控考勤机SDK使用中员工姓名的处理( c# )
公司使用的考勤机是中控的指纹考勤机,但是中控的型号乱七八糟,通过程序读出来的型号和实际标的型号不一致. 另外,提供的开发包的C#版本的Demo中调用 axCZKEM1.ReadAllUserID(iM ...
- python sort和sorted函数
sort 与 sorted 区别: sort 是应用在 list 上的方法,sorted 可以对所有可迭代的对象进行排序操作. list 的 sort 方法返回的是对已经存在的列表进行操作,而内建函数 ...
- python 元类(metaclass)
元类参见老师的博客 http://www.cnblogs.com/linhaifeng/articles/8029564.html
- 简单理解MapView 以及 设置 MKAnnotationView
MKMapView 相当于一个容器 .可以展示 MKAnnotationView.. 要使用它需要设置 数据源代理 _mapView.delegate = self; 它的数据源对象就是 符合 ...
- 91平台iOS接入demo
源码:http://pan.baidu.com/s/1DuBl6 今天整理硬盘,找到了一个有趣的demo.一年前,91助手游戏联运呈爆棚趋势,但是许多使用FlashAir开发的优秀的游戏和应用都卡在了 ...
- 深入理解Linux内核-页高速缓存
页高速缓存:1.磁盘高速缓存的一种 2.一种对完整的数据页进行操作的磁盘高速缓存.3.将一页数据写到块设备的时候,内核首先检查对应的页是否已经在高速缓存中,不在就添加并填充数据.4.I\O数据的传送并 ...
- android studio - Indexing paused due to batch updated
傻逼的 Android Studio 又开抽疯了.... 日 打开项目就出现 Indexing paused due to batch updated ,并且半天没反应........ 解决办 ...