Extjs4.x (MVC)Controller中refs以及Ext.ComponentQuery解析
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 FE > F
All direct children Components of E that match FE ^ 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.属性
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' }); /***********************************/
// 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)');
/* 商品控制层, 所有逻辑代码都在这里写 */ Ext.define('keel.controller.GoodsCtrl', {extend: 'Ext.app.Controller',stores: ['GoodsStore'],//声明该控制层要用到的storemodels: ['GoodsModel'],//声明该控制层要用到的modelviews: ['goods.GoodsListView','goods.GoodsWinView'],//声明该控制层要用到的viewrefs: [//相当于一个映射,这样就可以在控制层方便的通过geter取得相应的对象了{ref: 'goodslistview',selector: 'goodslistview'},{ref: 'goodswinview',selector: 'goodswinview'}],init: function() {this.control({//这里的this相当于这个控制层'viewport > goodslistview': {afterrender: function(gp){//侦听goodslistview渲染gp.down('button[action=testBtn1]').on('click',function(){//侦听goodslistview工具条上action=testBtn1的按钮单击事件this.showWin();},this);gp.down('button[action=testBtn2]').on('click',function(){//侦听goodslistview工具条上action=testBtn2的按钮单击事件alert(this.getGoodslistview().title)},this);}},'goodswinview button[action=ok]': {//侦听goodswinview中action=ok的按钮单击事件click: function(){this.getGoodswinview().setTitle(Ext.util.Format.date(new Date(),'Y-m-d H:i:s'));}}});},showWin : function(){Ext.create('keel.view.goods.GoodsWinView').show(); } });
转载于:https://blog.51cto.com/4925054/1363413
Extjs4.x (MVC)Controller中refs以及Ext.ComponentQuery解析相关推荐
- java注解返回不同消息,Spring MVC Controller中的一个读入和返回都是JSON的方法如何获取javax.validation注解的异常信息...
Spring MVC Controller中的一个读入和返回都是JSON的方法怎么获取javax.validation注解的错误信息? 本帖最后由 LonelyCoder2012 于 2014-03- ...
- Spring MVC Controller中返回json数据中文乱码处理
问题 在使用spring MVC Controller的过程中,发现返回到客户端的的中文出现乱码.后台Java代码: @RequestMapping(value = "/upload&quo ...
- MVC Controller中View(model)如何在 View中的index页面获得?
http://bbs.csdn.net/topics/390723984?page=1 在页面顶部定义 @model List<UserModel> 使用 @foreach(var x i ...
- .NET/ASP.NET MVC Controller 控制器(IController控制器的创建过程)
阅读目录: 1.开篇介绍 2.ASP.NETMVC IControllerFactory 控制器工厂接口 3.ASP.NETMVC DefaultControllerFactory 默认控制器工厂 4 ...
- Ext.app.controller的refs
简 单来说,就是4.0建议的MVC中controller引用组件的一种方式,selector中设置组件,可以用id.classname,但推荐用 ComponentQuery("组件检索&q ...
- asp.net mvc fckeditor全攻略(补充:Controller中传值的问题)
开篇仍然要叙述我的环境 环境说明: 软件环境:asp.net mvc3 + vs2010 系统环境:windows xp sp3 浏览器: ie8(为了世界的和平,为了社会的稳定,为了不再被大 ...
- spring mvc在Controller中获取ApplicationContext
spring mvc在Controller中获取ApplicationContext web.xml中进行正常的beans.xml和spring-mvc.xml的配置: 需要在beans.xml中进行 ...
- 【初学者指南】在ASP.NET MVC 5中创建GridView
介绍 在这篇文章中,我们将会学习如何在 ASP.NET MVC 中创建一个 gridview,就像 ASP.NET Web 表单中的 gridview 一样.服务器端和客户端有许多可用的第三方库,这些 ...
- Java Web学习总结(30)——Service层在MVC框架中的意义和职责
mvc框架由model,view,controller组成,执行流程一般是:在controller访问model获取数据,通过view渲染页面. mvc模式是web开发中的基础模式,采用的是分层设计, ...
最新文章
- 带你和Python与R一起玩转数据科学: 探索性数据分析(附代码)
- 在fedora21 上的php+mysql+apache环境搭建
- ASP.NET中 DropDownList+DetailsView(详细视图)的使用前台绑定
- 计算机专业学生求职信500字,计算机专业求职信500字范文
- (28)VHDL实现数码管直译
- python函数定义及调用-浅谈Python中函数的定义及其调用方法
- 数组对象 按某个属性排序
- nas918+支持的cpu_cpu拷机软件推荐:cpu烤机用什么软件
- javascript 图像二值化处理
- fanuc机器人与示教器配对_FANUC机器人示教器维修
- ExoPlayer播放器播放MP2音频格式视频无声音加入Ffmpeg软解码功能
- 计算机软件系统崩溃,电脑软件打开后闪退或崩溃怎么办
- python 排列 组合_python实现排列和组合
- 主题黑板.html,黑板报主题
- Java面向对象之创建和使用对象——定义学生/教师类并输出相关信息
- 计算机组老师颁奖词,教研组颁奖词5篇
- 一起认识国产又好用的uni-app
- UltraEdit 21.30.1006.0 繁体中文破解版(功能最强的文本编辑器)
- 数据人如何提高核心竞争力
- lisp倒入excel数据画图_如何将EXCEL中的数据导入CAD2007画图
热门文章
- iOS开发-UITableView常用方法
- Android+Jquery Mobile学习系列(3)-创建Android项目
- apache环境下web站点禁止用服务器ip访问
- jquery-easyui中表格的行编辑功能
- C# 判断上传图片是否被PS修改过的方法
- centos web服务器---sysctl.conf调优参数
- 【跃迁之路】【712天】程序员高效学习方法论探索系列(实验阶段469-2019.2.2)...
- 网络安全统计显示XSS和过时的软件是主要问题
- Oracle数据库merge into的使用,存在则更新,不存在则插入
- 相机技术公司Lytro获6000万美元D轮融资,阿里巴巴参投