2012-01-30 16 views
0

私は2つのタブパネルを作成し、各パネルにはグリッドがあります。Extjs 3 rowcontext destroy

グリッドAのためのリスナー:グリッドBのための

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

リスナー:

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メニューを右クリックではありません働く(小さな灰色の点が表示されます)。

私は戻ってグリッドAと右クリックに回した後、それはグリッドA上の2つのrowcontextのメニューを示しています。私は右のBグリッドとグリッドを右クリックしをクリックした場合

screenshot

を(何も示していない)の後Bグリッドに戻る グリッドBに2つのリスト(逆順)を含むrowcontextメニューを表示します。

なぜこのようなことが起こりますか?
グリッド行の各コンテキストメニューを正しく表示するにはどうすればよいですか?

答えて

0

この問題は明らかにパラメータグリッドまたはgrid.contextmenuによって発生します。

答えが見つかりました。

問題は、次の行によって発生します。

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

同じコンテキストメニューID 'ビュー'を使用しました。

これらの名前は、それが完璧に動作します

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

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

以下のように変更された後。

0

同じgrid変数を両方のリスナーに渡すようです。

+0

このパラメータは、インライン関数で使用しています。それは問題ではない – ShootingStar

関連する問題