ExtJS 4。 我有网格和编辑器。编辑有听众。如何从监听器访问网格?
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?;
}
}
}
}},
// ...
],
// ...
});
我可以合并编辑器而不是这个网格。所以这个命令需要是通用的。
答案 0 :(得分:1)
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
}
}
}
}},
// ...
],
// ...