Taking the "Expanding a Tree Node" example from the Flex 3 Tree Control
help at
http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_8.htm\
l and modifying it slightly I get this example:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
     creationComplete="initApp()">
     <mx:Script>
       <![CDATA[
         import mx.collections.XMLListCollection;

         [Bindable] private var treeData:XML =
             <root>
                 <node label="Monkeys">
                     <node label="South America">
                         <node label="Coastal"/>
                         <node label="Inland"/>
                     </node>
                     <node label="Africa" isBranch="true"/>
                     <node label="Asia" isBranch="true"/>
                 </node>
                 <node label="Sharks">
                     <node label="South America" isBranch="true"/>
                     <node label="Africa" isBranch="true"/>
                     <node label="Asia" >
                         <node label="Coastal"/>
                         <node label="Inland"/>
                     </node>
                 </node>
             </root>;

         private function initApp():void
         {
             var nodeList:XMLListCollection = myTree.dataProvider as
XMLListCollection;
             var nodes:XMLList = nodeList.source;
             expandSubNodes(nodes);
         }

         private function expandSubNodes(nodes:XMLList):void
         {
             for(var i:int = 0 ; i < nodes.length() ; i++)
             {
                 var n:XML = nodes[i];
                 if(n.children() != null)
                 {
                     myTree.expandItem(n,true,false);
                     expandSubNodes(n.children());
                 }
                 else
                 {
                     break;
                 }
             }
         }
       ]]>
     </mx:Script>
     <mx:Tree id="myTree" y="50" width="221" height="257"
horizontalCenter="0"
         dataProvider="{treeData.node}" labelField="@label"/>
</mx:Application>

HTH



Steve


--- In flexcoders@yahoogroups.com, "pbrendanc" <[EMAIL PROTECTED]> wrote:
>
> I want to auto expand my menu treeview immediately on open - the
> following code is called from thecreationComplete="initTree();" and
> expands the first node only.
>
> Is there a way to expand all nodes - I can't seem to get this to work.
> (Other have reported problems so I wonder if this is supported)?
>
> TIA,
> Patrick
>
> (The data provider for the tree is an XMLList)
>
>  <mx:XMLList id="menuData" >
>  <node label="Data Management">
>   <node label="Registration"/>
>   <node label="Customer List"/>
>  </node>
>  <node label="System Administration">
>   <node label="Add Users"/>
>  </node>
>
>
> private function initTree():void {
>
> //Expands first visible Tree Item
> menuTree.expandItem(menuTree.firstVisibleItem,true);
> }
>

Reply via email to