开发者

add node and expand GXT Async TreePanel

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.


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜