2012-09-27 39 views
0

我已經創建了contextmenu,當我點擊網格時顯示的選項右鍵單擊。根據我的新要求,我想添加條件,例如何時在網格上顯示右鍵單擊選項。對於一些特定的情況,我不想顯示那個右鍵點擊選項。Extjs:添加條件列表中的上下文菜單

我的代碼:

listeners : { 
     itemcontextmenu: function(dv, record, item, index, e) { 
     e.stopEvent(); // Prevent the browser to show its default contextmenu 
     this.contextMenu.index = index; // It's important! you'll need the rowIndex (the row that right clicked on it) on future. 
    this.contextMenu.showAt(e.getXY()); // Get the current X and Y coordinates and show the gridCtxMenu (my custom created menu) on that location. 
    var selectedUnitRecord = this.getStore().getAt(index); 
    selectedUnitId = selectedUnitRecord.get('id'); 
     } 
    } 

我REQ是我想補充一些東西像這樣的邏輯:

if(type == 'dc'){ 
     /*Show option*/ 
    }else{ 
     /*dont Show option*/ 
    } 

回答

0
listeners : { 
if(type == 'dc'){ 
return false; 
} 
     itemcontextmenu: function(dv, record, item, index, e) { 
     e.stopEvent(); // Prevent the browser to show its default contextmenu 
     this.contextMenu.index = index; // It's important! you'll need the rowIndex (the row that right clicked on it) on future. 
    this.contextMenu.showAt(e.getXY()); // Get the current X and Y coordinates and show the gridCtxMenu (my custom created menu) on that location. 
    var selectedUnitRecord = this.getStore().getAt(index); 
    selectedUnitId = selectedUnitRecord.get('id'); 
     } 
    } 
相關問題