[flexcoders] Re: Auto expand TreeView on open - How?
I tried menuTree.openItems = menuData..node; but the tree doesn't expand. What does work for me is callLater(menuTree.expandChildrenOf, [menuTree.dataProvider[0], true]); --- In flexcoders@yahoogroups.com, Paul Kukiel [EMAIL PROTECTED] wrote: I was stuck with this aswell a while ago this is my solution: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute creationComplete=init() mx:Script private function init():void{ menuTree.openItems = menuData..node; } /mx:Script mx:XML id=menuData node label=menu node label=Data Management node label=Registration/ node label=Customer List/ /node node label=System Administration node label=Add Users/ /node /node /mx:XML mx:Tree id=menuTree top=72 left=50 showRoot=false height=224 labelField=@label dataProvider={menuData}/ /mx:Application Paul K From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of pbrendanc Sent: Thursday, 4 December 2008 3:16 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Auto expand TreeView on open - How? 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); }
[flexcoders] Re: Auto expand TreeView on open - How?
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); }