When pruning all nodes from a TreeVirtual SimpleTreeDataModel prune(0), the nodes are recursively "deleted" by replacing the node array entries with null and removing these from any selections. When the tree is re-filled, the amount of data in the node array is increased. If this happens for a large tree several times over then the performance of the tree starts to degrade which is something noticed in our application.
Pruning at zero (root node) is a special case because all the nodes except root node are removed. The node array can be reset to a single root node and still maintain a nodeId == index correspondence for all new nodes as noted just below the amended code within the prune method. This allows prune and re-population to take place without growing the node array.
There is a method clearData of the datamodel which also does this, but causes the tree to be re-rendered which was not desirable in our use-case and the reason we were pruning in the first instance. Arguably that method could also be amended to suppress the re-render and used instead. I'm happy to take direction and amend as required.
When pruning all nodes from a TreeVirtual SimpleTreeDataModel
prune(0)
, the nodes are recursively "deleted" by replacing the node array entries with null and removing these from any selections. When the tree is re-filled, the amount of data in the node array is increased. If this happens for a large tree several times over then the performance of the tree starts to degrade which is something noticed in our application.Pruning at zero (root node) is a special case because all the nodes except root node are removed. The node array can be reset to a single root node and still maintain a nodeId == index correspondence for all new nodes as noted just below the amended code within the
prune
method. This allows prune and re-population to take place without growing the node array.There is a method
clearData
of the datamodel which also does this, but causes the tree to be re-rendered which was not desirable in our use-case and the reason we were pruning in the first instance. Arguably that method could also be amended to suppress the re-render and used instead. I'm happy to take direction and amend as required.