• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Expanding a tree node
 

Expanding a tree node

on

  • 2,719 views

Expanding a Tree Node in Flex

Expanding a Tree Node in Flex

Statistics

Views

Total Views
2,719
Views on SlideShare
2,713
Embed Views
6

Actions

Likes
0
Downloads
2
Comments
0

1 Embed 6

http://www.slideshare.net 6

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Expanding a tree node Expanding a tree node Presentation Transcript

    • Expanding a Tree Node Hemakumar.S Open Source Developer
    • Definition
      • 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.
    • Cont….
      • 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 "DMV" 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.
    • Source Code
      • <?xml version=&quot;1.0&quot;?>
      • <!-- dpcontrols/DrillIntoTree.mxml -->
      • <mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; creationComplete=&quot;initApp();&quot;>
      • <mx:Script>
      • <![CDATA[
      • import mx.collections.XMLListCollection;
      • [Bindable]
      • private var treeData:XML =
      • <root> <node label=&quot;Monkeys&quot;>
      • <node label=&quot;South America&quot;>
      • <node label=&quot;Coastal&quot;/>
      • <node label=&quot;Inland&quot;/>
      • </node> ]
      • <node label=&quot;Africa&quot; isBranch=&quot;true&quot;/>
      • <node label=&quot;Asia&quot; isBranch=&quot;true&quot;/>
      • </node>
    • Cont….
      • <node label=&quot;Sharks&quot;>
      • <node label=&quot;South America&quot; isBranch=&quot;true&quot;/>
      • <node label=&quot;Africa&quot; isBranch=&quot;true&quot;/>
      • <node label=&quot;Asia&quot; >
      • <node label=&quot;Coastal&quot;/>
      • <node label=&quot;Inland&quot;/>
      • </node>
      • </node>
      • </root>
      • private var openSequence:Array = [];
      • private function initApp():void
      • {
      • var paramLength:int = 0;
      • for (var s:String in Application.application.parameters)
      • { if (!isNaN(Number(s)))
      • { openSequence[s] = Application.application.parameters[s]; paramLength += 1;
      • }
      • }
    • Cont….
      • openTree();
      • }
      • private function openTree():
      • void
      • {
      • var nodeList:XMLListCollection = myTree.dataProvider as XMLListCollection; var node:XMLList = nodeList.source;
      • for(var i:int=0; i < openSequence.length; i++)
      • { var j:int = openSequence[i];
      • var n:XML = node[j];
      • if( n.children() != null )
      • { myTree.expandItem(n,true,false);
      • node = n.children();
      • }
      • else { break;
      • }
      • }
    • Cont….
      • if( n != null ) myTree.selectedItem = n;
      • }
      • ]]>
      • </mx:Script>
      • 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;/>
      • </mx:Application>
    • Screen Shot
    • Thank You....