gpt4 book ai didi

Extjs 3.4 checkchange 监听器不适用于 Checkcolumn

转载 作者:行者123 更新时间:2023-12-04 21:47:15 25 4
gpt4 key购买 nike

我的 checkColumn 的 checkchange 监听器不起作用。任何想法为什么不呢?

var checked = new Ext.grid.CheckColumn({
header: 'Test',
dataIndex: 'condition',
renderer: function(v,p,record){
var content = record.data['info'];
if(content == 'True'){
p.css += ' x-grid3-check-col-td';
return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
}

},
listeners:{
checkchange: function(column, recordIndex, checked){
alert("checked");
}

}

});

最佳答案

在 Ext.ux.grid.CheckColumn 中,添加这个注册 checkchange 事件的初始化方法:

initComponent: function(){
Ext.ux.grid.CheckColumn.superclass.initComponent.call(this);

this.addEvents(
'checkchange'
);
},

然后在 processEvent 中触发事件:

processEvent : function(name, e, grid, rowIndex, colIndex){
if (name == 'mousedown') {
var record = grid.store.getAt(rowIndex);
record.set(this.dataIndex, !record.data[this.dataIndex]);

// Fire checkchange event
this.fireEvent('checkchange', this, record.data[this.dataIndex]);

return false; // Cancel row selection.
} else {
return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
}
},

生成的 CheckColumn 组件应如下所示:

  Ext.ns('Ext.ux.grid');

Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
// private
initComponent: function(){
Ext.ux.grid.CheckColumn.superclass.initComponent.call(this);

this.addEvents(
'checkchange'
);
},

processEvent : function(name, e, grid, rowIndex, colIndex){
if (name == 'mousedown') {
var record = grid.store.getAt(rowIndex);
record.set(this.dataIndex, !record.data[this.dataIndex]);

this.fireEvent('checkchange', this, record.data[this.dataIndex]);

return false; // Cancel row selection.
} else {
return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
}
},

renderer : function(v, p, record){
p.css += ' x-grid3-check-col-td';
return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
},

// Deprecate use as a plugin. Remove in 4.0
init: Ext.emptyFn
});

// register ptype. Deprecate. Remove in 4.0
Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);

// backwards compat. Remove in 4.0
Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;

// register Column xtype
Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;

关于Extjs 3.4 checkchange 监听器不适用于 Checkcolumn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12390716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com