Build Tree from XMLListCollection : Tree Data « Components « Flex






Build Tree from XMLListCollection

      
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import flash.events.*;
        import mx.events.*;
        import mx.controls.*;
        private function changeEvt(event:Event):void {
            var theData:String = "";
            if (event.currentTarget.selectedItem.@data) {
                theData = " Data: " + event.currentTarget.selectedItem.@data;
            }
            forChange.text = event.currentTarget.selectedItem.@label + theData;
        }
        private function itemOpenEvt(event:TreeEvent):void {
            forOpen.text = event.item.@label;
        }
      
    </mx:Script>
    <mx:Tree id="XMLtree1" width="150" height="170" labelField="@label" itemOpen="itemOpenEvt(event);" change="changeEvt(event);">
        <mx:XMLListCollection id="MailBox">
            <mx:XMLList>
                <node label="Doc" data="100">
                    <node label="Chapter 1" data="70" />
                    <node label="Chapter 2" data="10">
                        <node label="Section 1" data="2" />
                        <node label="Section 2" data="3" />
                        <node label="Section 3" data="0" isBranch="true" />
                        <node label="Section 4" data="5" />
                    </node>
                    <node label="Pdf" data="15" />
                    <node label="Rdf" data="5" />
                </node>
            </mx:XMLList>
        </mx:XMLListCollection>
    </mx:Tree>
    <mx:Label text="Change Event:" />
    <mx:TextArea id="forChange" width="150" />
    <mx:Label text="Open Event:" />
    <mx:TextArea id="forOpen" width="150" />
</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.Use ActionScript to set up the data provider for Tree controlUse ActionScript to set up the data provider for Tree control
7.Fill XML data into Tree and get it back when selectedFill XML data into Tree and get it back when selected
8.AdvancedDataGrid with Grouping(A tree table).AdvancedDataGrid with Grouping(A tree table).
9.Tree uses an XMLListCollection object as the data source:Tree uses an XMLListCollection object as the data source:
10.Tree with static dataTree with static data
11.Hierarchical AdvancedDataGrid Tree Column(TreeTable)Hierarchical AdvancedDataGrid Tree Column(TreeTable)
12.Use an XML object and Tree controlUse an XML object and Tree control
13.Tree control and XMLListCollectionTree control and 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