Expanding a Tree Node Hemakumar.S Open Source Developer
Definition <ul><li>Tree control displays the root node or nodes of the tree when it first opens. If you want to expand a n...
Cont…. <ul><li>At the tail end of Flex 3, several customers were in need of a Tree that could handle ItemPendingErrors. Th...
Source Code <ul><li><?xml version=&quot;1.0&quot;?>  </li></ul><ul><li><!-- dpcontrols/DrillIntoTree.mxml --> </li></ul><u...
Cont…. <ul><li><node label=&quot;Sharks&quot;>  </li></ul><ul><li><node label=&quot;South America&quot; isBranch=&quot;tru...
Cont…. <ul><li>openTree();  </li></ul><ul><li>}  </li></ul><ul><li>private function openTree(): </li></ul><ul><li>void  </...
Cont…. <ul><li>if( n != null ) myTree.selectedItem = n;  </li></ul><ul><li>}  </li></ul><ul><li>]]>  </li></ul><ul><li></m...
Screen Shot
Thank You....
Upcoming SlideShare
Loading in …5
×

Expanding a tree node

4,024 views
3,956 views

Published on

Expanding a Tree Node in Flex

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,024
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Expanding a tree node

  1. 1. Expanding a Tree Node Hemakumar.S Open Source Developer
  2. 2. Definition <ul><li>Tree control displays the root node or nodes of the tree when it first opens. If you want to expand a node of the tree when the tree opens, you can use the expandItem() method of the Tree control. The following change to the example in Handling Tree control events calls the expandItem() method as part of the Tree control's creationComplete event listener to expand the root node of the tree. </li></ul>
  3. 3. Cont…. <ul><li>At the tail end of Flex 3, several customers were in need of a Tree that could handle ItemPendingErrors. The shortest route to such a thing was to create a subclass of Tree that could handle the Advanced DataGrid's HierarchicalCollectionView. the acronym &quot;DMV&quot; throughout because the AdvancedDataGrid and HierarchicalCollectionView are part of the Data Management and Visualization package (which requires the Professional versions and/or more money) so those of you trying to go the cheap route won't be able to leverage this code. Also, you won't need this unless your data source throws ItemPendingErrors when an attempt is made to fetch data that hasn't been paged in yet, and unless you developed your own, you are using one of our data services which also cost you some money. </li></ul>
  4. 4. Source Code <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!-- dpcontrols/DrillIntoTree.mxml --> </li></ul><ul><li><mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; creationComplete=&quot;initApp();&quot;> </li></ul><ul><li><mx:Script> </li></ul><ul><li><![CDATA[ </li></ul><ul><li>import mx.collections.XMLListCollection; </li></ul><ul><li>[Bindable] </li></ul><ul><li>private var treeData:XML = </li></ul><ul><li><root> <node label=&quot;Monkeys&quot;> </li></ul><ul><li><node label=&quot;South America&quot;> </li></ul><ul><li><node label=&quot;Coastal&quot;/> </li></ul><ul><li><node label=&quot;Inland&quot;/> </li></ul><ul><li></node> ] </li></ul><ul><li><node label=&quot;Africa&quot; isBranch=&quot;true&quot;/> </li></ul><ul><li><node label=&quot;Asia&quot; isBranch=&quot;true&quot;/> </li></ul><ul><li></node> </li></ul>
  5. 5. Cont…. <ul><li><node label=&quot;Sharks&quot;> </li></ul><ul><li><node label=&quot;South America&quot; isBranch=&quot;true&quot;/> </li></ul><ul><li><node label=&quot;Africa&quot; isBranch=&quot;true&quot;/> </li></ul><ul><li><node label=&quot;Asia&quot; > </li></ul><ul><li><node label=&quot;Coastal&quot;/> </li></ul><ul><li><node label=&quot;Inland&quot;/> </li></ul><ul><li></node> </li></ul><ul><li></node> </li></ul><ul><li></root> </li></ul><ul><li>private var openSequence:Array = []; </li></ul><ul><li>private function initApp():void </li></ul><ul><li>{ </li></ul><ul><li>var paramLength:int = 0; </li></ul><ul><li>for (var s:String in Application.application.parameters) </li></ul><ul><li>{ if (!isNaN(Number(s))) </li></ul><ul><li>{ openSequence[s] = Application.application.parameters[s]; paramLength += 1; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  6. 6. Cont…. <ul><li>openTree(); </li></ul><ul><li>} </li></ul><ul><li>private function openTree(): </li></ul><ul><li>void </li></ul><ul><li>{ </li></ul><ul><li>var nodeList:XMLListCollection = myTree.dataProvider as XMLListCollection; var node:XMLList = nodeList.source; </li></ul><ul><li>for(var i:int=0; i < openSequence.length; i++) </li></ul><ul><li>{ var j:int = openSequence[i]; </li></ul><ul><li>var n:XML = node[j]; </li></ul><ul><li>if( n.children() != null ) </li></ul><ul><li>{ myTree.expandItem(n,true,false); </li></ul><ul><li>node = n.children(); </li></ul><ul><li>} </li></ul><ul><li>else { break; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  7. 7. Cont…. <ul><li>if( n != null ) myTree.selectedItem = n; </li></ul><ul><li>} </li></ul><ul><li>]]> </li></ul><ul><li></mx:Script> </li></ul><ul><li>mx:Tree id=&quot;myTree&quot; y=&quot;50&quot; width=&quot;221&quot; height=&quot;257&quot; horizontalCenter=&quot;0&quot; dataProvider=&quot;{treeData.node}&quot; labelField=&quot;@label&quot;/> </li></ul><ul><li></mx:Application> </li></ul>
  8. 8. Screen Shot
  9. 9. Thank You....

×