我正在使用extjs 4,我有一个显示字段名称Approval的网格.这里我显示了复选框,如果值为true,将在加载网格时检查该复选框.但如果dataIndex值为fault,则仅显示复选框.现在我希望如果我单击未选中的复选框,它将使用侦听器执行操作.但我无法做到这一点.有人可以帮我这个吗?我的代码如下:
{
text: 'Approval',
dataIndex: 'approve',
flex: 1,
align: 'left',
renderer: function(value, metaData, record, row, col, store, gridView){
if(value == true)
{
return '<input type="checkbox" checked="true" />';
}else{
return '<input type = "checkbox" />';
listeners: {
this.approve();
}
}
}
}
approve: function(){
alert('hi');
}
Run Code Online (Sandbox Code Playgroud)
该复选框有一个更改侦听器,该值将在值更改后触发.
{
xtype : 'checkbox'
boxLabel : 'This is my checkbox',
name : 'mycheckbox',
inputValue: true,
listeners : {
change: function(cbx, newValue, oldValue){
me.approve();
}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,您无法this在侦听器内部使用,因为该函数在另一个范围内被调用.
开始Ext.ux.CheckColumn在网格上使用a .
现在你可以使用:
{
xtype: 'checkcolumn',
text: 'Approval',
dataIndex: 'approve',
flex: 1,
align: 'left',
sortable: false,
listeners:{
checkchange:function(cc,ix,isChecked){
alert(isChecked);
}
}
}
Run Code Online (Sandbox Code Playgroud)