2012-01-30 51 views
0

我创建了两个选项卡面板,每个面板都有一个网格。Extjs 3 rowcontext destroy

监听网格答:

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 rowcontext菜单上不工作(只显示小灰点)。

后,我回头电网和右侧点击,它显示网格的两个rowcontext菜单:

screenshot

如果我在B方格纹点击右键,网格右击后(没有任何显示)回到B格 它显示rowcontext菜单,其中包含两个列表(相反的顺序)在网格B上。

为什么会发生这种事情?
如何正确显示每个网格行上下文菜单?

回答

0

此问题显然是由参数网格或grid.contextmenu引起的。

我找到了答案。

该问题是由下面的线引起的。

items: [{ id: 'view', text: 'View Task'}] 

我使用了相同的上下文菜单id'view'。

后的名称变更,如以下

items: [{ id: 'viewTask', text: 'View Task'}] 

items: [{ id: 'viewContent', text: 'View Content'}] 

它可以完美运行。

0

看来你将两个听众一样的grid变量。

+0

该参数在内联函数中使用。这不是问题 – ShootingStar 2012-01-30 22:11:35