Javascript 如何从网格编辑器中选择网格?

Javascript 如何从网格编辑器中选择网格?,javascript,extjs,web,Javascript,Extjs,Web,extjs4。 我有网格和编辑器。编辑有听众。如何从侦听器访问网格 var grid = Ext.create('Ext.grid.Panel',{ plugins: [Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 2, pluginId: 'cellplugin' })], columns: [ { header: 'Name', dataIndex: 'name', edit

extjs4。 我有网格和编辑器。编辑有听众。如何从侦听器访问网格

var grid = Ext.create('Ext.grid.Panel',{
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToEdit: 2,
    pluginId: 'cellplugin'
})],
columns: [
    {
    header: 'Name',
    dataIndex: 'name',
    editor: {
        xtype: 'textfield',
        listeners: {
            specialkey: function(field, e) {
                if (e.getKey() == e.ENTER) {
                    !!!NEED TO ACCESS GRID HERE, FOR EXAMPLE IN VARIABLE!!!
                    var grid = SOME?CODE?;
                }
            }
        }
    }},
    // ...
],
// ...
}))


我可以不从这个网格合并编辑器。所以这个命令必须是通用的。

如果我不在每个网格中添加itemId,它可能会更好。在这种情况下,您可以使用xtype选择器
this.up('gridpanel')
No。网格变量未定义,即使我使用
code
this.up('#gridpanel')
code
<代码>代码只有Ext.getCmp()
代码
有效。我不这样做。试试,
field.ownerCt
并向上遍历?不。field没有这个方法。字段似乎位于它自己的对象树中。通过使用超类,我访问了抽象组件,但并没有看到我的网格或类似的东西。如果只是一些类型的字段。
var grid = Ext.create('Ext.grid.Panel',{
itemId : 'gridPanel',   //we need to call your grid somehow
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToEdit: 2,
    pluginId: 'cellplugin'
})],
columns: [
    {
    header: 'Name',
    dataIndex: 'name',
    editor: {
        xtype: 'textfield',
        listeners: {
            specialkey: function(field, e) {
                if (e.getKey() == e.ENTER) {
                    var grid = this.up('#gridPanel'); //and access it like this
                }
            }
        }
    }},
    // ...
],
// ...