我创建了contextmenu,当我点击网格时,右键单击显示选项。根据我的新要求,我想添加条件,比如何时在网格上显示右键单击选项。对于某些特定情况,我不想显示右键单击选项。
我的代码:
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*/
}
答案 0 :(得分: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');
}
}