I am using this plugin for showing a tree.
Does it have any functionality which will check all child nodes when parent node is checked?
Currently I can't find any way to do this.
To achieve this functionality I have written recursive function to find each node under root and check using checkNode function.
I see a performance issue when depth of the tree is more than 3 for around 150 nodes. On investigation I found checkNode function in bootstrap-treeview.js uses render each time node is checked, can anyone tell me the use of this render function?
Can we remove use of render?
I was struggling with performance using a recursive solution as well, but I found a more efficient alternative. The call to
checkAllis fast, even with large trees, because it only makes a single call torender, while a recursive implementation of this checking usingcheckNodewill callrendermany times unnecessarily, as you pointed out.I couldn't find this in the documentation, but I noticed that
checkNodecallsforEachIdentifierin its implementation, the same ascheckAll, so you can actually pass in an array of nodes or nodeIds, instead of just a single nodeId, and it will only callrenderonly once, after all the nodes are checked. The only difference forcheckAllis that it specifically passes in all the nodeIds in the tree.So you can just add some code in your event handler to generate the list of nodeIds for all nodes underneath the parent, by looking at the id of the last child node and building a range, then call
checkNodeonce.Edit: revised code to properly handle the case where the last child has children.