1. #11
    Sencha Premium Member
    Join Date
    Apr 2008
    Posts
    266
    Vote Rating
    28
    themightychris has a spectacular aura about themightychris has a spectacular aura about

      0  

    Default


    I've encountered the same problem, is this an intended grid behavior or a side-effect from the browser?
    Chief Architect @ Jarv.us Innovations
    Co-captain @ Code for Philly

    Jarvus builds and optimizes top-quality Sencha Touch and ExtJS apps for open-source projects and clients of all sizes.

    Don't waste time with bugs that have already been found and fixed by the community, compile our tried and tested hotfixes packages into all your projects: https://github.com/JarvusInnovations/sencha-hotfixes

  2. #12
    Sencha User
    Join Date
    Sep 2010
    Location
    Pune,India
    Posts
    23
    Vote Rating
    0
    rvaibhav is on a distinguished road

      0  

    Default


    nobody's listening

  3. #13
    Sencha Premium Member
    Join Date
    Mar 2011
    Posts
    8
    Vote Rating
    1
    Daniel Salvi is on a distinguished road

      1  

    Default 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);
            }
        }
    });

  4. #14
    Sencha User
    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    1
    lxu is on a distinguished road

      0  

    Default


    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.

  5. #15
    Sencha User
    Join Date
    Sep 2011
    Posts
    4
    Vote Rating
    0
    gtbhalala is on a distinguished road

      0  

    Default 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);
    }
    }
    });