This may seem counter-productive to some, but, I need to be able to dynamically delete and rebuild a tree structure. The thing is, I need the data to always be real-time…

 

So, given the tree following:

 

A

|  A1

|    A1.1

B

 

How do I, when the user clicks the A node, delete everything beneath it so that I can rebuild it?

 

I have tried various things, but, nothing seems to work. The only way I can see to do it is,

 

                HtmlTree tree = (HtmlTree) component;

                selectedNode = (TreeNodeBase) tree.getNode();

                selectedNode.getChildren().removeAll(selectedNode.getChildren());

 

But, this does not work. When the tree is rebuilt, the nodes seem to keep the state of the node that previously occupied that position.

Here is what happens:  if the user selects A, then selects A1 (to expand them), and then collapses A by selecting it again, everything looks normal. But if he then selects A to expand it (again), the code is supposed to delete everything below A and rebuild the first level below A (like lazy loading). This appears to work also, but, A1, though it has been deleted and newly created, has the state of being expanded – forcing you to select it twice to expand it…

 

Is there some way to COMPLETELY remove everything below a node? Or, is my description not clear enough of what is going on?

 

Thanks for any help…

 

 

Reply via email to