定期更新 EXTJS 4 Treepanel

发布于 2024-11-02 07:39:24 字数 583 浏览 0 评论 0原文

我想创建一个 Treepanel,每秒更新一次。 因此,我采用了带有代理的存储来获取数据:

store = new Ext.data.TreeStore({
    model: 'TaskState',
        proxy: {
        type: 'ajax',
        url : '/getTaskList'
},
    root: {
        expanded: true
}});

该存储似乎可以正常工作,数据显示在我的 TreePanel 中。

我尝试使用此功能更新 Treepanel

function refresh(){
        store.load();
        window.setTimeout("refresh()", 1000);
    }

更新似乎也有效。不幸的是,更新会在每次更新时导致某种“闪烁”效果,因为整个树都会重新加载。我正在寻找一种仅刷新已更改节点的方法。

有什么方法可以做到这一点吗?

问候

I would like to create a Treepanel, which is updated once a second.
So I took a store with a proxy for data acquistion:

store = new Ext.data.TreeStore({
    model: 'TaskState',
        proxy: {
        type: 'ajax',
        url : '/getTaskList'
},
    root: {
        expanded: true
}});

The store seems to work, the data is displayed in my TreePanel.

I tried to update the Treepanel with this function:

function refresh(){
        store.load();
        window.setTimeout("refresh()", 1000);
    }

The update seems to work as well. Unfortunately the update causes some kind of "blinking" effekt on every update, because the whole tree is reloaded. I'm searching for a way to only refresh the nodes, which have changed.

Is there some way to do this?

greetings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

多情癖 2024-11-09 07:39:24

有一种方法:
您可以将节点加载到某个临时存储并逐个节点更改主树的存储

There is one way:
You can load your nodes to some temp store and change your main tree's store node by node

吝吻 2024-11-09 07:39:24

如果您想添加任何新节点并且不想重新加载整个商店,那么您可以像这样添加

 //overModel is Ext.data.Model
 overModel.appendChild({
                        id: responseJson.data['id'],
                        text:responseJson.data['text'],
                        children:responseJson.data['children'],//array of childern
                        parent_id:responseJson.data['parent_id']

  });
  overModel.expand();

,如果您想加载整个商店,您可以执行类似这样的操作

Ext.data.StoreManager.lookup( 'StoreName').load({ params: {"p1": p1}});

加载商店。
要定期更新商店,您可以使用 DelatedTask< /a> 类。

查看 EXTJS 的 Documentation API 将为您提供更多详细信息。

If you want to add any new node and do not want to reload the whole store then you can add like this

 //overModel is Ext.data.Model
 overModel.appendChild({
                        id: responseJson.data['id'],
                        text:responseJson.data['text'],
                        children:responseJson.data['children'],//array of childern
                        parent_id:responseJson.data['parent_id']

  });
  overModel.expand();

and if you want to load the whole store the you can do something like this

Ext.data.StoreManager.lookup('StoreName').load({ params: {"p1": p1}});

to load the store.
To update the store periodically you can use DelatedTask Class.

check out the Documentation API of EXTJS will give you more details.

述情 2024-11-09 07:39:24

商店像网格和商店一样绑定树面板,因此您可以从树面板获取商店

var store=treepanel.getStore()

,并且可以使用需要更新的分支重新加载商店

store.load({node:selectedNode})

Store is bind Treepanel like grid and store ,so you can get Store from tree panel with

var store=treepanel.getStore()

and you can reload the store with branch that you need update with

store.load({node:selectedNode})
戏舞 2024-11-09 07:39:24

您可以使用 TaskManager 来实现:

Ext.TaskManager.start({
    run: reloadStoreFunction,
    interval: 1000
});

这将每秒执行 reloadStoreFunction 。

You could use TaskManager for that:

Ext.TaskManager.start({
    run: reloadStoreFunction,
    interval: 1000
});

This would execute reloadStoreFunction every second.

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