更新树面板的最佳方法是什么
我想知道,更新数据库后同步/加载树面板的最佳方法是什么。 今天,我做了一个 Ajax 请求来进行更新。如果响应成功,我将使用我的 treeStore 的方法加载。
myTreePanel.getStore.load();
但这种技术浪费时间。也许这不是最好的技术?!
谢谢 :)
I would like know , what is the best way to sync/load tree panel after updating database.
Today, i do an Ajax Request to make an updates. If the response is successful i use method load of my treeStore.
myTreePanel.getStore.load();
But this technic waste times . Maybe is not the best technic to do this ?!
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果用户更新节点&您向服务器/数据库提交更改,无需重新加载树,只需更新该节点
node.setText('BlahBlah')
但如果它有多个节点或更新来自服务器&当前用户尚未更改它们(其他用户的树更改和当前用户仅看到更改)我将通过 websocket 和当前用户的更改来更新 UI如果 websockets 不可能,我会通过每 20-30 秒左右执行 ajax 请求来获取更改。我想说的是,最好更改一小部分 UI,因为它具有更好的性能和功能。 DOM 不会改变太多,而且你也不必获取所有节点,即使那些没有改变的节点。
if user updates a node & you commit changes to server/database you don't need to reload tree, just update that node
node.setText('BlahBlah')
but if it's more than one node or updates are comming from server & current user hasn't changed them (tree changes by other users & current user just sees changes) i would update UI with comming changes via websocket & if websockets wasn't possible i would fetch changes by doing ajax request every 20-30 seconds or so.the thing i'm trying to say is it's better to change a small set of UI because it has better performance & DOM won't change so much, also you don't have to fetch all nodes, even those have not changed.