开发者

Dojo treemodel- adding large number of items

开发者 https://www.devze.com 2022-12-23 07:43 出处:网络
I am trying to add a large number of items (100+) to my tree via ForestStoreModel by calling newItem in a loop.This seems to be quite slow and locks up the browser.Is there any way I can do something

I am trying to add a large number of items (100+) to my tree via ForestStoreModel by calling newItem in a loop. This seems to be quite slow and locks up the browser. Is there any way I can do something similar to grid's beginUpdate & endUpdate? I want to basically 'turn off' my tree, add 100 items in a b开发者_JS百科atch, then 'turn on' my tree. Any ideas? Thanks!


As Stephen Chung suggested, the best way would be to only add nodes that the user requires at a specific node level; but sometimes you may have a large number of nodes at the same level or other things might get in the way. In order to update the tree with a large number of items all at once, I would suggest creating a new store/updating your old store, then you need to refresh the tree rendering. So once the store has the correctly formatted array, do this (credit to Layke for the hack How to update dojo tree data dynamically):

            // Completely delete every node from the dijit.Tree     
            myTree._itemNodesMap = {};
            myTree.rootNode.state = "UNCHECKED";
            myTree.model.root.children = null;

            // Destroy the widget
            myTree.rootNode.destroyRecursive();

            // Recreate the model, (with the model again)
            myTree.model.constructor(myTree.model);

            // Rebuild the tree
            myTree.postMixInProperties();
            myTree._load();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号