最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ExtJs自定义组件事件绑定两个实例
时间:2022-06-25 18:28:54 编辑:袖梨 来源:一聚教程网
例1
优化了一下代码,结果如下。
调用:
代码如下 | 复制代码 |
组件定义
代码如下 | 复制代码 |
Ext.define('WX.student.AddStudent', { modal:true, }); |
例2
新件一个JS文件
代码如下 | 复制代码 |
// JavaScript Document 编号:{ID} ',' 姓名:{FirstName}-{LastName} ',' 电话:{Phone} ',' 城市:{City} ',' 邮箱:{Email} ']), initComponent:function(){ CRM.Panels.UserDetail.superclass.initComponent.call(this); if(typeof this.tpl === 'string'){ this.tpl = new Ext.XTemplate(this.tpl); } this.addEvents('UAlert');//注册新事件 this.addListener({//侦听函数 UAlert: { //注册的新事件 fn:this.onAlert,//调用onAlert方法 scope: this } }); }, ////////////// onAlert: function(){ alert('注册的新事件'); }, UAlert:function(){ this.fireEvent('UAlert'); }, ///////////////////// onRender: function(ct, position){ CRM.Panels.UserDetail.superclass.onRender.call(this, ct, position); if(this.data){ this.update(this.data); } }, update: function(data){ this.data = data; this.tpl.overwrite(this.body, this.data); // this.fireEvent('update',this.data); } }); //把新建的自定义组件注册为一种xtype
|
在页面上:
代码如下 | 复制代码 |
|
相关文章
- 火影忍者怎么获得大招 05-03
- 星际战甲新手什么刀好 05-03
- 文明6秦始皇金字塔怎么加速 05-03
- 全民奇迹2龙骸巨剑怎么获得 05-03
- 星露谷物语鲟鱼怎么获得 05-03
- 长安幻想怎么转职 05-03