Rows state is by row index not row ID unfortunately (I sumbitted an
issue on this). As a result you will have that issue. Best thing you
can do is write a custom tree state object for your model or manually
expand/collapse the paths when you add/remove nodes.
BTW - You shouln't have to rebuild the branch, but simply remove the
nodes you need to (unless you really need to rebuild the nodes for
some reason).
-Andrew
On 6/17/06, Hughes, Stan <[EMAIL PROTECTED]> wrote:
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…