You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Todd Patrick <To...@dtn.com> on 2006/06/15 23:43:47 UTC

Automatically expand a tree once I dynamically populate a node with children?

Tree2 is working great.
 
A topic that I cannot find in the demo code or in the mail archive is
how would I automatically expand the tree once I dynamically populate a
node with children?
 
For example, I have the following tree:
 
|- A
|- B
|- C
 
I click on node B and that runs an ActionListener that populates the
children for node B and I get the following:
 
|- A
+- B
|- C
 
I still have to click on the plus sign "+" to see the children after I
dynamically loaded the children from a database.
 
What I would like to have happen when I click on node B that runs an
ActionListener that populates the children for node B; the tree
automatically expands and display the children:
 
|- A
|--B
|  |_ 1
|  |_ 2
|  |_ 3
|
|- C
 
Thoughts or suggestions are greatly appreciated.
 
Thanks,
 
--Todd
 
 

Re: Automatically expand a tree once I dynamically populate a node with children?

Posted by Andrew Robinson <an...@gmail.com>.
call your model's state and expand the path manually. The expanded
state is a list of node indexes. so in this case, you need to make
sure path "1" is expanded for node 'B'

Check the WIKI and this mailing list's archives for more discussions
on dynamic tree loading and manually expanding/collapsing nodes.

-Andrew

PS - would give you references, but really busy at the moment, sorry

On 6/15/06, Todd Patrick <To...@dtn.com> wrote:
>
>
> Tree2 is working great.
>
> A topic that I cannot find in the demo code or in the mail archive is how
> would I automatically expand the tree once I dynamically populate a node
> with children?
>
> For example, I have the following tree:
>
>
> |- A
> |- B
> |- C
>
> I click on node B and that runs an ActionListener that populates the
> children for node B and I get the following:
>
> |- A
> +- B
> |- C
>
> I still have to click on the plus sign "+" to see the children after I
> dynamically loaded the children from a database.
>
> What I would like to have happen when I click on node B that runs an
> ActionListener that populates the children for node B; the tree
> automatically expands and display the children:
>
>
> |- A
> |--B
> |  |_ 1
> |  |_ 2
> |  |_ 3
> |
> |- C
>
> Thoughts or suggestions are greatly appreciated.
>
> Thanks,
>
> --Todd
>
>