Where the XML comes from shouldn't matter.  Think of XML as a tree of
nodes each with a unique id (UID).  The Tree tracks the UIDs of nodes
that are open.
 
If you change the XML enough, the set of nodes, even if they look the
same, may have new UIDs and thus the set of open items and calls to
expandItem may not work.
 
Also note that if you bind to the XMLListCollection, you risk changes to
the collection causing the collection to be re-assigned and thus flush
the open items list.
 
Thus:
[Bindable[
var xmlc:XMLListCollection;
<mx:Tree id="foo" dataProvider="{xmlc"} />
 
may end up resetting the dataProvider as you modify xmlc.
 
var xmlc:XMLListCollection
<mx:Tree id="foo"  initialize="foo.dataProvider=xmlc" />
 
Will not reset as it is not watching the collection for bindable
changes.  Similarly, if you assign the dataProvider on the result of the
server fetch, you'll be safer that way too.

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Baljeet singh
Sent: Wednesday, September 05, 2007 9:19 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Tree collapses when dataProvider for tree
changes



Hi,

Actually, i am using XML string, that is coming from server side. 
>From that XML string, i get the XMLListCollection as dataProvider.
When i click on selected node, either i am editing th information 
related to node or creating children. This edited/children information 
is stored in database.
So, dataProvider changes(it's required). Tree is 
created on the basis of "id" attribute of each XML node . When 
dataProvider changes, i again retrieve that node on basis of "id" 
attribute. Then i tried to use expandItem() method, selectedItem etc, 
providing the retrieved node. But it's not working.

Thanks & Regards 
Baljeet



 

Reply via email to