添加节点并展开 GXT Async TreePanel

发布于 2024-10-25 04:43:51 字数 473 浏览 5 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┼── 2024-11-01 04:43:53

尝试删除 loaderLoad 方法以及 loaderLoadException 中的侦听器以避免泄漏

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

锦爱 2024-11-01 04:43:53

我建议存储选择要重新加载的节点(向您添加一个 onClick 侦听器)。比在 loaderLoad 中检查存储的对象是否等于加载节点的父节点:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文