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:
public void loaderLoad(LoadEvent le)
GWT.log("******************************** I'm Inside");
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.
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