Use ActionScript to set up the data provider for Tree control : Tree Data « Components « Flex






Use ActionScript to set up the data provider for Tree control

Use ActionScript to set up the data provider for Tree control
      
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="creationCompleteHandler(event)">
    <mx:Script>
        
            import mx.collections.ArrayCollection;
            import mx.controls.List;

            private function creationCompleteHandler(event:Event):void {
                var array:Array = new Array({label: "CA", children: new Array(
                                                      {label: "Los Angeles"},
                                                      {label: "San Francisco"})},
                                            {label: "MA", children: new Array(
                                                      {label: "Boston"})});
                var collection:ArrayCollection = new ArrayCollection(array);
                tree.dataProvider = collection;
            }

      
    </mx:Script>
    <mx:Tree id="tree" labelField="label" width="200" />
</mx:Application>

   
    
    
    
    
    
  








Related examples in the same category

1.XML data for Tree viewXML data for Tree view
2.Reference XML attribute for tree dataReference XML attribute for tree data
3.Set dataProvider for Tree control through xml attributeSet dataProvider for Tree control through xml attribute
4.Using XML data models and use it as data for Tree controlUsing XML data models and use it as data for Tree control
5.Tree data is from XMLListCollectionTree data is from XMLListCollection
6.Fill XML data into Tree and get it back when selectedFill XML data into Tree and get it back when selected
7.AdvancedDataGrid with Grouping(A tree table).AdvancedDataGrid with Grouping(A tree table).
8.Tree uses an XMLListCollection object as the data source:Tree uses an XMLListCollection object as the data source:
9.Tree with static dataTree with static data
10.Hierarchical AdvancedDataGrid Tree Column(TreeTable)Hierarchical AdvancedDataGrid Tree Column(TreeTable)
11.Use an XML object and Tree controlUse an XML object and Tree control
12.Tree control and XMLListCollectionTree control and XMLListCollection
13.Build Tree from XMLListCollection
14.Search Tree node is to search XML with XPathSearch Tree node is to search XML with XPath
15.Build a tree out of an XML documentBuild a tree out of an XML document
16.Tree controls uses an XML object directlyTree controls uses an XML object directly
17.Create Tree object from XMLListCreate Tree object from XMLList
18.Tree with static valueTree with static value