A few things to consider.

 

1)       How are you adding nodes?.  If you use XML as the dataProvider
and use the XML API to add the nodes, the tree will not collapse.

2)       After you programatically change a dataProvider, you need to
use callLater to defer any interaction with the Tree control, to allow
it to render first.

3)       If you use XML as the tree dataProvider, you can use e4x
expressions to find the node by its Id property, rather then iterating
recursively over the collection.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Baljeet singh
Sent: Thursday, September 06, 2007 5:40 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Tree collapses when dataProvider for tree
changes

 

Hi,

Lets consider an XML as tree of nodes. Let me explain u the meaning of
"id".  My sample XML string look like:

<node>                                        <!--First Level -->

    <node id="1" name="A" code="1">    <!--Second Level -->

              <node id="2" name="A-1" code="1-1"/> <!--Third Level -->

              <node id="3" name="A-2" code="1-2">  

                     <node id="4" name="A-2-1" code="1-2-1"/>   <!--
Fourth Level-->

                      <node id="5" name="A-2-2" code="1-2-2"/>.
.
             </node>

    </node>

   <!-- & So on--->

</node>

 Here my each XML node has unique Id attribute. 

Now suppose I create a tree with this XML & i click on any node. For the
selected node, say node with id="5", i can find out the value of "id"
attribute of selected node & save this in session object. Means now i
have idea about which node i selected.

Now suppose , i create two children for selected node i.e for node with
id="5". So my XML changes somewhat like below:

<node>                                        <!--First Level -->

    <node id="1" name="A" code="1">    <!--Second Level -->

              <node id="2" name="A-1" code="1-1"/> <!--Third Level -->

              <node id="3" name="A-2" code="1-2">  

                     <node id="4" name="A-2-1" code="1-2-1"/>   <!--
Fourth Level-->

                      <node id="5" name="A-2-2" code="1-2-2"/>.   

                               <node id="100" name="A-2-2-1"
code="1-2-2-1"/>      < !-- Level 5th--->

                                <node id="101" name="A-2-2-2"
code="1-2-2-2"/>                .
             </node>

    </node>

   <!-- & So on--->

</node>

 So my dataProvider changes & tree gets collapsed.

 As we have already stored the id attribte value of selected node in
session. Now we can iterate over XMLListCollection to find the XML  node
with that  particular id value.

& Now  i use expandItem() method  & selectedItem property, providing
selected node. But  none of these things works.

Thanks & Regards,

Baljeet

  

 

 

Reply via email to