So, as ankit chaudhary tells us, one needs to remove the navigationModel. I thought a navigationModel
could be useful and decided to override the navigationModel to adapt it to my requirement:
Ext.define('MyApp.override.NavigationModel', {
override : 'Ext.grid.NavigationModel',
scrollOnFocus: true,
constructor: function(config) {
this.callParent(arguments);
if(Ext.isBoolean(config.scrollOnFocus)) this.scrollOnFocus = config.scrollOnFocus;
},
onCellMouseDown: function(view, cell, cellIndex, record, row, recordIndex, mousedownEvent) {
var actionableEl = mousedownEvent.getTarget(this.isFocusableEl, cell);
if (!this.scrollOnFocus && !view.actionableMode && mousedownEvent.pointerType !== 'touch' && mousedownEvent.position.column.cellFocusable !== false && !actionableEl) return;
this.callParent(arguments);
},
onItemMouseDown: function(view, record, item, index, mousedownEvent) {
var me = this,
scroller;
if (!mousedownEvent.position.cellElement && (mousedownEvent.pointerType !== 'touch')) {
if (!view.enableTextSelection) {
mousedownEvent.preventDefault();
}
me.attachClosestCell(mousedownEvent);
if (me.scrollOnFocus && !me.position.isEqual(mousedownEvent.position)) {
me.setPosition(mousedownEvent.position, null, mousedownEvent);
}
scroller = view.getScrollable();
if (scroller) {
scroller.restoreState();
}
}
}
});
Now I can add to my grid's viewConfig a customized navigationModel
:
viewConfig: {
navigationModel:{
type:'grid',
scrollOnFocus: false
}
}
and the grid does no longer scroll on a mouse click.