【问题标题】:Extjs how to capture when the checkbox is checked or unchecked in xtype: 'checkcolumn'Extjs如何在xtype中选中或取消选中复选框时捕获:'checkcolumn'
【发布时间】:2014-05-01 22:51:13
【问题描述】:

我是 EXTJS 的新手。我有一个网格,其中有复选框列。我想要的是,如何捕获复选框中发生的选中或取消选中事件。

这是我的网格中复选框的代码

    columns : [

             {
            xtype: 'checkcolumn',
                   header: 'Enabled',
              dataIndex: 'isEnabled',
              width: 55
           },
        ....
         ]

请帮忙

【问题讨论】:

标签: extjs checkbox


【解决方案1】:

正如 Evan Trimboli 所说,通过网格上的 checkchange 事件,您可以在复选框更改值时捕获。

Ext.create('Ext.grid.Panel', {
    //...
    columns  : [{ 
        xtype: 'checkcolumn',
        header: 'Enabled',
        dataIndex: 'isEnabled',
        width: 55,
        listeners: {
            checkchange: function(column, rowIdx, checked, eOpts){
                //Logic here
            }
        }
    }],
});

【讨论】:

  • checkchange 事件未在网格上提供,而是在列上可用。
  • 有没有办法阻止复选框编辑此事件?例如,如果我们执行一些逻辑然后取消选中...
  • @KremenaLalova 请参考this question
  • 感谢您的帮助!
【解决方案2】:

给出的答案有一点变化,checkchange事件是针对Ext.grid.column.check而不是针对Ext.grid.Panel

Ext.create('Ext.grid.Panel', {
//...
columns  : [{ 
    xtype: 'checkcolumn',
    header: 'Enabled',
    dataIndex: 'isEnabled',
    width: 55,
    listeners: {
        checkchange: function(column, rowIdx, checked, eOpts){
            //Logic here
    }
    }
}]
});

【讨论】:

    猜你喜欢
    • 2013-07-24
    • 1970-01-01
    • 2013-10-21
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-19
    相关资源
    最近更新 更多