Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选择网格中的特定单元格-Ext JS_Javascript_Extjs - Fatal编程技术网

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

Javascript 选择网格中的特定单元格-Ext JS,javascript,extjs,Javascript,Extjs,我在此处设置了一个控制器,用于侦听网格行上的单击: init: function() { this.control({ 'mygrid': { select: this.viewDesc //On click... } }); }, 现在,无论单击哪个单元格,都会触发此事件。但是,我想监听特定列/单元格的单击 这是如何实现

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

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

上面的代码片段取自上一个问题

您可以使用网格的
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'));
                }
            }
        }
    });
},

以上代码片段摘自上一个问题

谢谢你,Nandkumar,你是goldenIs有没有办法从不同的值中选择cellIndex?比如一个数据索引?我的意思是,我可以不使用“if(cellIndex==3)”,而使用“if(cellIndex.dataIndex==“popup”)?我不确定,我认为使用
视图
是可能的,我会检查并告诉你Hank you Nandkumar,你是goldenIs有没有办法从不同的值中选择cellIndex?比如一个数据索引?我的意思是,我可以做一些类似于“如果(cellIndex.dataIndex==”弹出窗口“,”的事情,而不是“如果(cellIndex==3)”?我不确定,我认为使用
视图
是可能的,我会检查并告诉你