extjs3行上下文销毁
我创建了两个选项卡面板,每个面板都有一个网格 网格A的侦听器:extjs3行上下文销毁,extjs,extjs3,Extjs,Extjs3,我创建了两个选项卡面板,每个面板都有一个网格 网格A的侦听器: Ext.getCmp('AGrid').addListener("rowcontextmenu", function menus(grid, rowIndex, e) { if (!grid.contextMenu) { grid.contextMenu = new Ext.menu.Menu({ autoDestroy: false,
Ext.getCmp('AGrid').addListener("rowcontextmenu", function menus(grid, rowIndex, e) {
if (!grid.contextMenu) {
grid.contextMenu = new Ext.menu.Menu({
autoDestroy: false,
items: [{ id: 'view', text: 'View Content'}],
currentRowIndex: rowIndex,
listeners: {
itemclick: function (item) {
switch (item.id) {
case 'view':
viewEmailClick(grid.getStore().getAt(this.currentRowIndex).data);
break;
}
}
}
});
}
this.contextMenu.currentRowIndex = rowIndex;
e.stopEvent(); // this stops the browser context menu and allows the default grid
// show the row context menu here
this.contextMenu.showAt(e.xy);
});
网格B的侦听器:
Ext.getCmp('BGrid').addListener("rowcontextmenu", function menus(grid, rowIndex, e) {
if (!grid.contextMenu) {
grid.contextMenu = new Ext.menu.Menu({
autoDestroy: false,
items: [{ id: 'view', text: 'View Task'}],
currentRowIndex: rowIndex,
listeners: {
itemclick: function (item) {
switch (item.id) {
case 'view':
viewTicketClick(grid.getStore().getAt(this.currentRowIndex).data);
break;
}
}
}
});
}
this.contextMenu.currentRowIndex = rowIndex;
e.stopEvent(); // this stops the browser context menu and allows the default grid
// show the row context menu here
this.contextMenu.showAt(e.xy);
});
当我用鼠标右键点击它时,网格A工作正常,然后右键点击网格B行上下文菜单不工作(只显示小灰点)
返回网格A并单击鼠标右键后,在网格A上显示两个行上下文菜单:
如果我在B网格上单击鼠标右键,在返回B网格后,在A网格上单击鼠标右键(没有显示任何内容)
它显示行上下文菜单,其中包含网格B上的两个列表(顺序相反)
为什么会发生这种事情?如何正确显示每个网格行上下文菜单?似乎您向两个侦听器传递了相同的
grid
变量。此问题显然是由参数grid或grid.contextmenu引起的
我找到了答案
该问题是由以下行引起的
items: [{ id: 'view', text: 'View Task'}]
我使用了相同的上下文菜单id“视图”
在这些名字改变后,如下所示
items: [{ id: 'viewTask', text: 'View Task'}]
items: [{ id: 'viewContent', text: 'View Content'}]
它工作得非常完美。该参数正在使用at内联函数。这不是问题所在