-
7 Aug 2011 9:21 AM #11
I've encountered the same problem, is this an intended grid behavior or a side-effect from the browser?
-
18 Aug 2011 4:27 AM #12
-
28 Sep 2011 8:06 PM #13
patch
patch
Hi,
Disabling events may cause unpredictable side-effects, I'd rather stick to applying patches. Those below seem to work fine on 4.0.6:
Code:/** * Grid focus issue * * http://www.sencha.com/forum/archive/index.php/t-142291.html? * http://www.sencha.com/forum/showthread.php?136674-Howto-disable-grid-focus-on-click/page2 */ Ext.override(Ext.selection.RowModel, { onRowMouseDown: function (view, record, item, index, e) { //view.el.focus(); if (!this.allowRightMouseSelection(e)) { return; } this.selectWithEvent(record, e); } }); Ext.override(Ext.grid.plugin.CellEditing, { onEditComplete : function(ed, value, startValue) { var me = this, grid = me.grid, sm = grid.getSelectionModel(), activeColumn = me.getActiveColumn(), dataIndex; if (activeColumn) { dataIndex = activeColumn.dataIndex; me.setActiveEditor(null); me.setActiveColumn(null); me.setActiveRecord(null); delete sm.wasEditing; if (!me.validateEdit()) { return; } // Only update the record if the new value is different than the // startValue, when the view refreshes its el will gain focus if (value !== startValue) { me.context.record.set(dataIndex, value); // Restore focus back to the view's element. } else { /** * Line commented out! */ //grid.getView().getEl(activeColumn).focus(); } me.context.value = value; me.fireEvent('edit', me, me.context); } } });
-
31 Jan 2013 11:49 PM #14
Sencha, are you going to fix this? Is there even a bug logged for this?
Actually, I'm only bothered by the initial click where the grid shifting happens. After that, subsequent clicks don't shift the grid anymore.
The fix suggested above does not work in 4.1.3. I've traced down the problem to where it wants to call el.focus() on the dom. This focus can be disabled by:
Ext.override(Ext.selection.RowModel, {
preventFocus: true
});
But I don't know what side-effects it may introduce.
-
18 Apr 2013 4:13 PM #15
Grid Focus issue fix for ExtJs 4.0.3
Grid Focus issue fix for ExtJs 4.0.3
I had the same issue, but I am using grid with CheckboxModel
I have overridden the "onRowMouseDown" method of "Ext.selection.CheckboxModel" class.
and it resolved the issue for me
Here is the code snippet
Ext.override(Ext.selection.CheckboxModel, {
onRowMouseDown: function (view, record, item, index, e) {
//view.el.focus(); // Commented this code to not to focus the grid view on row click.
var me = this,
checker = e.getTarget('.' + Ext.baseCSSPrefix + 'grid-row-checker'),
mode;
if (!me.allowRightMouseSelection(e)) {
return;
}
// checkOnly set, but we didn't click on a checker.
if (me.checkOnly && !checker) {
return;
}
if (checker) {
mode = me.getSelectionMode();
// dont change the mode if its single otherwise
// we would get multiple selection
if (mode !== 'SINGLE') {
me.setSelectionMode('SIMPLE');
}
me.selectWithEvent(record, e);
me.setSelectionMode(mode);
} else {
me.selectWithEvent(record, e);
}
}
});


Reply With Quote