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 ...
随机推荐
- TF 设置GPU模式训练
https://blog.csdn.net/confuciust/article/details/78982264 在终端执行程序时指定GPU CUDA_VISIBLE_DEVICES=1 pytho ...
- fiddler 抓取iphone发出的http和https包
1.清理iphone的描述文件,在通用里面设置.这一步目的防止手机里面已经存在了DO_NOT_TRUST_FiddlerRoot证书,导致后面抓不了包,所以先清理下 2.下载安装fiddler,百度或 ...
- springcloud中概念辨析
1 什么是微服务? 微服务架构是一种架构模式或者一种架构风格,他提倡将单一应用程序划分成一组小的服务,每个服务运行在独立进程中,服务之间相互协调.相互配合.服务之间采用轻量级的通信机制(一般是基于HT ...
- java中多个数字运算后值不对(失真)处理方法
最近遇到一个bug ,在java里面计算两个数字相减,633011.20-31296.30 得到的结果居然是601714.8999999999,丢失精度了,原来这是Java浮点运算的一个bug. 解决 ...
- JavaScript监听手机物理返回键的两种解决方法
JavaScript没有监听物理返回键的API,所以只能使用 popstate 事件监听. 有两个解决办法: 1.返回到指定的页面 pushHistory(); window.addEventList ...
- jQueryWEUI自定义对话框-带有textarea
jQueryWEUI 示例下载 在jQueryWEUI中提供了很多类型的对话框, 可以去访问看一下. 今天记录的则是,自己定义的一个带有文本域的对话框,这样,可以不通过调转页面,实现一些信息的提交. ...
- Vuex 入门指南
1.Vuex是什么? 我们还是像以往一样先看一看官方文档对此的解读(Vuex 是什么? · GitBook) Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的 ...
- Java 里如何实现线程间通信
正常情况下,每个子线程完成各自的任务就可以结束了.不过有的时候,我们希望多个线程协同工作来完成某个任务,这时就涉及到了线程间通信了. 本文涉及到的知识点:thread.join(), object.w ...
- iptables防火墙与日志系统配合使用 监控服务器特点端口的防问源IP
/etc/sysconfig/iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 5 --log-prefix "PORT_80:& ...
- 实例分析JVM安全体系:双亲委派、命名空间、保护域、策略
在了解双亲委派模型之前,先了解一下类加载器的概念: 类加载器的作用就是将真实的class文件根据位置将该Java类的字节码装入内存,并生成对应的Class对象.用户可以通过继承ClassLoader和 ...