Extjs 不要在右键单击时更改CheckColumn值
我找不到如何在带有复选框列的网格中正确打开上下文菜单。每当在复选框单元格上执行右键单击时,复选框都会切换。这不是上下文菜单所期望的Extjs 不要在右键单击时更改CheckColumn值,extjs,Extjs,我找不到如何在带有复选框列的网格中正确打开上下文菜单。每当在复选框单元格上执行右键单击时,复选框都会切换。这不是上下文菜单所期望的 onAdminListCellContextMenu: function(tableview, td, cellIndex, record, tr, rowIndex, e, eOpts) { e.stopEvent(); // this is where the right click should have been stopped from toggl
onAdminListCellContextMenu: function(tableview, td, cellIndex, record, tr, rowIndex, e, eOpts) {
e.stopEvent(); // this is where the right click should have been stopped from toggling the button underneath!?
var sample = Ext.getCmp('AdminListContextMenu') || new Admin.view.AdminListContextMenu;
sample.showAt(e.xy);
}
从我的网格面板调用:
xtype: 'gridpanel',
flex: 1,
id: 'AdminList',
store: 'AdminStore',
columns: [{
xtype: 'gridcolumn',
dataIndex: 'user',
text: 'User',
editor: {xtype: 'textfield'}
},{
xtype: 'checkcolumn',
dataIndex: 'admins',
text: 'Grant admin rights'
}],
listeners: {
cellcontextmenu: {
fn: me.onAdminListCellContextMenu,
scope: me
}
}
试试这个,让我知道结果
xtype: 'gridpanel',
flex: 1,
id: 'AdminList',
store: 'AdminStore',
selModel: Ext.create('Ext.selection.CheckboxModel', {
selType: 'checkboxmodel',
mode: 'SIMPLE',
checkOnly: true,
allowDeselect: true,
ignoreRightMouseSelection: true
},
multiSelect: true,
columns: [{
xtype: 'gridcolumn',
dataIndex: 'user',
text: 'User',
editor: {xtype: 'textfield'}
},{
xtype: 'checkcolumn',
dataIndex: 'admins',
text: 'Grant admin rights'
}],
listeners: {
beforeitemmousedown: {
function(grid, record, item, index, e, eOpts) {
if (e.button == 0) {
allowSelection = true;
} else {
allowSelection = false;
return false;
}
}
},
cellcontextmenu: {
fn: me.onAdminListCellContextMenu,
scope: me
}
}
在ExtJS 6.0.1中测试,使用风险自负。Thx供您尝试,但我没有发现行为上的任何差异。甚至添加
window.alert(true)没有更改任何内容,因此不会触发此事件。我只是尝试了BeforeCellContextMenu事件-效果是现在复选框仍处于切换状态,但我的上下文菜单不再打开。啊,顺便说一句,第二次值得一提的是,函数中的window.alert不会导致弹出窗口吗?upps,然后在grid listener范围之外尝试此函数。原因是想看看会发生什么。通过Ext.getCmp('AdminList')获取网格。在…
亲爱的Alex,我将尝试使用ExtJS小提琴,让我花点时间。
Ext.define('Ext.override.CheckColumn',{
override:'Ext.grid.column.Check',
processEvent:function(type, view, cell, recordIndex, cellIndex, e, record, row) {
if(type == "mousedown" && e.button > 0) return; // prevent mousedown event if mouse button not the left button.
return this.callParent(arguments);
}
});