添加节点并展开 GXT Async TreePanel
我有一个 Async TreePanel,它使用 RPC 代理从服务器加载数据。我想通过使用以下方式重新加载节点:
this.treeLoader.loadChildren(nodeModel);
然后,我希望加载的树节点展开。我尝试:
treePanel.setExpanded(nodeModel, true, false);
但第一次调用是异步的,因此“setExpanded”发生在节点加载之前。
一种解决方案是在 treeLoader 上使用 LoadListener 并在加载其子节点后展开该节点,但侦听器的 loaderLoad(..) 方法无法直接知道重新加载的原因:也许用户展开了一个节点,这触发了重新加载或者用户可能单击菜单选项来重新加载节点。
有什么方法可以改进这一点,以便在用户想要重新加载节点后更容易触发节点展开?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试删除 loaderLoad 方法以及 loaderLoadException 中的侦听器以避免泄漏
Try removing the listener in the loaderLoad method, as well as in the loaderLoadException to avoid a leak
我建议存储选择要重新加载的节点(向您添加一个 onClick 侦听器)。比在 loaderLoad 中检查存储的对象是否等于加载节点的父节点:
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: