Ext自定义事件

本文介绍了ExtJS框架中两种自定义事件监听的方法:一种是在GridPanel行数据中添加自定义按钮并实现其事件响应;另一种是在重写组件时自定义对象属性与行为。这两种方法能够增强ExtJS应用的交互性和功能性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在ext中常见的2中自定义事件监听.

1、在gridpanel中行数据中增加自定义的按钮,图标的事件操作。例如:

代码如下: 注意: action-col-css

{xtype:'grid',
	columns:[
		{text: '编写说明',flex: 1,dataIndex: 'caseid',align: 'center',renderer:function(v, m, r){
			return '<span key="uploadimg" class="action-col-css x-fa fa-upload" style="font-size: 18px;cursor:pointer;"></span>';
		}}
	],
	processEvent : function(type, view, cell, recordIndex, cellIndex, e, record, row){
		if(type === 'click'){
			var target = e.getTarget(),
	            actionIdRe = 'action-col-css';
			if(target.className.indexOf(actionIdRe)!=-1){
				var key = target.attributes.key.value;
				console.log(key);  //key 就是uploadimg
			}
		}
		return Ext.callback(this.superclass.processEvent,this,[type, view, cell, recordIndex, cellIndex, e, record, row]);
	}
}


2. 重写组件时自定义对象

例如: 

Ext.define('app.expand.ux.IconClsField', {
    extend: 'Ext.form.field.Picker',
    xtype: 'iconclsfield',

    beforeBodyEl: [
        '<div style="position: absolute;width: 24px;height: 24px;left: 4px;top: 0px;bottom: 0px;margin: auto;text-align:center;font-size:16px;" >' +
            '<div id="{id}-swatchEl" data-ref="swatchEl" class="fa fa-expand" ' +
            	'style="width:24px;height:24px;text-align:center;line-height:24px;font-size:16px;float:left;color:#5fa2dd;">' + 
            '</div>' +
        '</div>'
    ],
	
	childEls: [
        'swatchEl' //data-ref
    ],
	
	setValue:function(v){
       var me = this;
       if(me.swatchEl)me.swatchEl.setCls(v);  //直接获取me.swatchEl对象
       me.superclass.setValue.call(me,v);
    }
});




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值