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

Selecting specific cells in a grid - Ext JS

本文关键字:单元格 Ext JS 网格 选择      更新时间:2023-09-26

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

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

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

如何实现这一点?

您可以使用

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'));
                }
            }
        }
    });
},

上面的代码片段取自我对您上一个问题的回答