instead of just calling openTree(), need to actually use:
callLater(openTree);

http://www.cflex.net/showFileDetails.cfm?ObjectID=570

If only I'd found it sooner... :D


--- In flexcoders@yahoogroups.com, "nathanpdaniel" <ndan...@...> 
wrote:
>
> I'm attempting to open all nodes in a Tree control (expandItem on 
> everything possible).  There's plenty of code out there explaining 
> how to do it - works GREAT on static data.  But, I'm loading XML 
data 
> from an external source and deriving an XML Tree from that data at 
> runtime.  I set my Tree controls dataProvider property to my new 
> XMLList/XMLListCollection I create, and no nodes get 
> opened/expanded.  I can loop through it and see which items SHOULD 
> get opened, but when I actually look at the Tree control, no nodes 
> are opened.  I can take the same data I generate and create a 
static 
> variable in the Script block or MXML (say <mx:XMLListCollection 
> id='xlc'><mx:XMLList><item label="one"><item 
> label="two"/></item></mx:XMLList></mx:XMLListCollection> or var 
> xlc:XMLListCollection = new XMLListCollection(new XMLList(<item 
> label='one'><item label='two'/></item>); ) and it'll work every 
time 
> I run it.  But when I try something like:
> 
> function initTree():void
> {
>  // where xmlList is loaded at runtime
>  myTree.dataProvider = new XMLListCollection(xmlList);
>  openTree();
> }
> function openTree():void
> {
>  var xlc:XMLListCollection = myTree.dataProvider as 
XMLListCollection;
>  var node:XMLList = xlc.source;
>  for (var i:int = 0; i < node.length(); i++)
>  {
>    if (node.children() != null)
>      myTree.expandItem(node, true);
>  }
> }
> 
> I can run this code, and looping through openTree(), 
> myTree.expandItem get's "run" for all the appropriate nodes 
> (although, this particular function will only open nodes one level 
> below the root - my actual function has a bit more to open all 
> nodes), however, in the display, none are actually opened just 
looks 
> like: > one
> Any ideas?
>


Reply via email to