0
votes

I've an Async TreePanel that uses an RPC proxy to load data from server. I want to reload a node by using:

this.treeLoader.loadChildren(nodeModel);

Then, I want the loaded tree node to become expanded. I tried to:

treePanel.setExpanded(nodeModel, true, false);

but the first call is asynchronous so the "setExpanded" happens before the nodes get loaded.

A solution would be to use a LoadListener on the treeLoader and expand the node after it's children are loaded but the listener's loaderLoad(..) method can't know directly the reason for the reload: maybe the user expanded a node and this triggered the reload or maybe the user clicked on a menu option to reload the node.

Is there any way to improve this so it's easier to trigger the node expand after the user wants to reload a node?

Thanks.

2

2 Answers

1
votes

Try removing the listener in the loaderLoad method, as well as in the loaderLoadException to avoid a leak

0
votes

I suggest to store the node that was selected to be reloaded (add a onClick listener to the thee). Than in the loaderLoad check if the stored object equals the parent of loaded node:

loader.addLoadListener(new LoadListener() {
    @Override
    public void loaderLoad(LoadEvent loadEvent) {
        ModelData parent = loadEvent.getConfig();
        if(parent.equals(storedObject) {
            // your code here