【问题标题】:Selecting specific cells in a grid - Ext JS选择网格中的特定单元格 - Ext JS
【发布时间】:2013-10-11 21:30:53
【问题描述】:

我在这里设置了一个控制器来监听对网格行的点击:

   init: function() {
            this.control({
                'mygrid': {
                    select: this.viewDesc //On click...
                }
            });
        },

现在,无论单击哪个单元格,都会触发此事件。但是,我想监听特定列/单元格的点击。

如何做到这一点?

【问题讨论】:

标签: javascript extjs


【解决方案1】:

您可以为网格使用cellclick 事件,并识别用户点击了哪个单元格,它会类似于:

init: function() {
    this.control({
        'mygrid': {
            cellclick: function(view, td, cellIndex, record, tr, rowIndex, e, eOpts) {
                // if clicked on cell 4, show popup otherwise ignore
                if(cellIndex == 3) { // cellIndex starts from 0
                    Ext.Msg.alert('Selected Record', 'Name : ' + record.get('firstname') + ' ' + record.get('lastname'));
                }
            }
        }
    });
},

上面的代码sn-p取自my answer到你之前的问题

【讨论】:

  • 谢谢 Nandkumar,你是金子
  • 有没有办法从不同的值中选择 cellIndex ?比如dataIndex?
  • 我的意思是,我可以用 'if(cellIndex.dataIndex == "popup")' 代替 'if(cellIndex == 3)' 吗?
  • 我不确定,我认为view 可以,我会检查并告诉你
猜你喜欢
  • 2011-10-05
  • 2011-01-07
  • 1970-01-01
  • 2012-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-14
  • 1970-01-01
相关资源
最近更新 更多