定期更新 EXTJS 4 Treepanel
我想创建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一种方法:
您可以将节点加载到某个临时存储并逐个节点更改主树的存储
There is one way:
You can load your nodes to some temp store and change your main tree's store node by node
如果您想添加任何新节点并且不想重新加载整个商店,那么您可以像这样添加
,如果您想加载整个商店,您可以执行类似这样的操作
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
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.
商店像网格和商店一样绑定树面板,因此您可以从树面板获取商店
,并且可以使用需要更新的分支重新加载商店
Store is bind Treepanel like grid and store ,so you can get Store from tree panel with
and you can reload the store with branch that you need update with
您可以使用 TaskManager 来实现:
这将每秒执行 reloadStoreFunction 。
You could use TaskManager for that:
This would execute reloadStoreFunction every second.