选择网格中的特定单元格 - Ext JS

时间:2013-10-04 18:55:46

标签: javascript extjs

我在这里设置了一个控制器,用于侦听网格行上的点击:

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

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

如何实现这一目标?

1 个答案:

答案 0 :(得分: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'));
                }
            }
        }
    });
},

以上代码段从my answer转到上一个问题

相关问题