1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    3
    Vote Rating
    0
    mario.amaya is on a distinguished road

      0  

    Default Unanswered: Select first row from Tree Grid when loaded

    Unanswered: 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:

    center.add(initTree().getTreeGrid());

    tree.getTreeStore().getLoader().addLoadListener(new LoadListener()
    {
    @Override
    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 - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    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.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar