1. #1
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default Howto disable grid focus on click?

    Howto disable grid focus on click?


    I have a simple grid loaded from a remote store. When a user clicks a cell it calls focus and repositions the browser window to the grid. I do not want this behavior. Grid Panel docs suggest using focusOnToFront which I set to false but it still doesn't do anything. any ideas? Disabling all focus/click events on the grid panel works for me if there's a way to do that.

    You can reproduce this only on Chrome, not firefox on the example page.
    Open this example, scroll to the top of the page, make your chrome window smaller coming mid way over the grid and then click on a row. The browser scrolls down.. why

    http://dev.sencha.com/deploy/ext-4.0.../xml-grid.html

  2. #2
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    any ideas? is this a bug?

  3. #3
    Sencha User
    Join Date
    May 2010
    Location
    Kent, UK
    Posts
    3
    Vote Rating
    0
    Dem0liti0n is on a distinguished road

      0  

    Default Howto disable grid focus on click? answer

    Howto disable grid focus on click? answer


    Not sure if you ever came around solving this. For all

    This is a functionality which could potentially build up to a bug/unwanted behaviour...
    This can be solve by disabling all listeners on the grid e.g.

    Code:
    itemsGrid.disableEvents(true);

    or the specific event (onclick)...

  4. #4
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    I don't see disableEvents() method on the grid panel.. ? thanks for the reply!

  5. #5
    Sencha User
    Join Date
    May 2010
    Location
    Kent, UK
    Posts
    3
    Vote Rating
    0
    Dem0liti0n is on a distinguished road

      0  

    Lightbulb Yes there is a disableEvents(boolean disable) method

    Yes there is a disableEvents(boolean disable) method


    Hi Netslayer,

    There is:
    Code:
      /** 
       * True to disable event processing. 
       *  
       * @param disable true to disable 
       */  
      public void disableEvents(boolean disable) {  
        disableEvents = disable;  
      }
    Note: this would also take away mouse roll-over and roll-off listeners. The instance that I have use this for didn't require this functionality neither.


    see http://www.sencha.com/gxtdocs/codese...onent&line=375

    let me know how you get on...

  6. #6
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    I'm using Extjs4 so I don't have access to that method. I have tried suspendEvents(false) on the grid and it doesn't help. It's easily reproducible in the example grid in chrome.

  7. #7
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    I can replicate this behavior very simply on a grid in chrome by just calling view focus. The page jumps down to the grid. Any ideas on how to disable this?

    Ext.getCmp('myGrid').getView().focus();

  8. #8
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    Found a solution:
    Ext.getCmp('myGrid').getView().suspendEvents(false);

    It doesn't make sense that a grid view has a focus event that repositions the pages viewport on click.

  9. #9
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    -1
    netslayer is an unknown quantity at this point

      0  

    Default


    The problem I had with suspendEvents is obviously it broke the load event on the grid which was needed. Wrote a quick function to remove the culprit managed listener "mousedown" that's on the grids view.

    I call this with disableGridClick(grid.getView());
    Code:
    function disableGridClick(view) {
        var managedListeners = view.managedListeners || [],
            i = 0,
            len = managedListeners.length;
    
        for (; i < len; i++) {
            if (managedListeners[i].ename == 'mousedown') {
                view.removeManagedListenerItem(true, managedListeners[i]);
            }
        }
    }

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

      0  

    Exclamation


    For me the problem is more severe. I cannot disable grid events as I need them.
    I'm using cellEditing plugin. So when I disable mousedown, it works for non-editable cells. But when I click editable cell, it again calls focus, grid shifts up and js exception is thrown 'event is null'.

    Any solution preferrably w/o disabling grid events?

    thx

    Vaibhav