在ExtJS 4中,他们在网格面板上引入了空格键切换选择。我希望能够覆盖onKeyPress并禁用它。 (我不想禁用enableKeyNav)
我尝试了什么;
//This didn't work....
Ext.override('Ext.selection.RowModel', {
onKeyPress: function(e, t) {
console.log(e);
}
});
//This also didn't work...
Ext.define('MyApp.selection.RowModel', {
override: 'Ext.selection.RowModel',
onKeyPress: function(e, t) {
console.log(e);
}
});
相关主题; ExtJS 4 Grid Panel - Spacebar row toggle
我要覆盖的源代码;
// Select/Deselect based on pressing Spacebar.
// Assumes a SIMPLE selectionmode style
onKeyPress: function(e, t) {
if (e.getKey() === e.SPACE) {
e.stopEvent();
var me = this,
record = me.lastFocused;
if (record) {
if (me.isSelected(record)) {
me.doDeselect(record, false);
} else {
me.doSelect(record, true);
}
}
}
},
答案 0 :(得分:0)
所以似乎onKeyPress在4.2.2中不存在,这就是我所使用的。
结束了......
Ext.define('MyApp.selection.RowModel', {
override: 'Ext.selection.RowModel',
onKeySpace: function(e) {
console.log(e);
}
});