0

我已经创建了上下文菜单,当我单击网格时,它会在右键单击时显示选项。根据我的新要求,我想添加条件,例如何时在网格上显示右键单击选项。对于某些特殊情况,我不想显示该右键单击选项。

我的代码:

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

我的要求是我想添加一些类似这样的逻辑:

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

1 回答 1

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');
        }
   }
于 2012-09-27T08:56:21.000 回答