Results 1 to 2 of 2

Thread: Select first row from Tree Grid when loaded

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Vote Rating

    Default Select first row from Tree Grid when loaded

    Hi guys, I want to select the first row from a tree grid when the tree grid is loaded.

    Here is my code:


    tree.getTreeStore().getLoader().addLoadListener(new LoadListener()
    public void loaderLoad(LoadEvent le)
    tree.getTreeGrid().getSelectionModel().select(0, false);
    GWT.log("******************************** I'm Inside");

    center.setLayout(new FitLayout());

    But it's not working, any ideas on how this should work?

    If I put tree.getTreeGrid().getSelectionModel().select(0, false); inside a button it works, but I want to do it when the treegrid is loaded.

  2. #2
    Sencha User
    Join Date
    Feb 2009
    Vote Rating


    From your use of FitLayout, I think this is a GXT 2 question, yet in the GXT 3 forums.

    The problem likely is that you are performing this selection based on the event handler going off *before* the other handlers have had time to do their work. Additionally, the Grid (and so the TreeGrid) may defer its work slightly for better performance.

    Each event may have multiple handlers listening to it - this Load event, for example, goes to the code you shared, but also to the store, so it can add items. You should *never* assume that two handlers will go off in a specific order, since if a line of code gets moved, or an unrelated class is changed, this order could be affected. Instead, consider adding a deferred command to actually do this work, or listen for the TreeGrid to fire an event (like Refresh or ViewReady, I'm unsure exactly what will work in this case), informing other code that the UI is now up to date again.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts