qooxdoo / qooxdoo

qooxdoo - Universal JavaScript Framework
http://qooxdoo.org
Other
764 stars 259 forks source link

Allow clearData to be called for a TreeVirtual without a re-render of the tree #10638

Closed rad-pat closed 6 months ago

rad-pat commented 6 months ago

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.

rad-pat commented 6 months ago

Updated with the requested changes to clearData that seem to work well.