Add selected value from Tree and add it to List : Tree « Components « Flex






Add selected value from Tree and add it to List

Add selected value from Tree and add it to List
      

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    height="400">
    <mx:Script>
        
        import mx.collections.XMLListCollection;
        import mx.collections.ArrayCollection;
        [Bindable]
        public var myData:XML=
        <catalog>
            <category name="Meat">
                <product name="A" cost="4" isOrganic="No" isLowFat="Yes"/>
                <product name="B" cost="6" isOrganic="No" isLowFat="No"/>
                <product name="C" cost="1.5" isOrganic="Yes" isLowFat="No"/>
            </category>
        </catalog>;
        
        [Bindable]
        public var listDP:XMLListCollection = new XMLListCollection(new XMLList());
        
        private function doTreeSelect():void
        {
            if (prodTree.selectedItem)
                listDP.addItem(prodTree.selectedItem.copy());
        }
        private function doListRemove():void
        {
            if (prodList.selectedItem)
                listDP.removeItemAt(prodList.selectedIndex);
        }
      
    </mx:Script>
    <mx:Tree id="prodTree" dataProvider="{myData}" width="200" showRoot="false" labelField="@name" />
    <mx:HBox>
        <mx:Button id="treeSelect" label="Add to List" click="doTreeSelect()" />
        <mx:Button id="listRemove" label="Remove from List" click="doListRemove()" />
    </mx:HBox>
    <mx:List id="prodList" dataProvider="{listDP}" width="200" labelField="@name" />
</mx:Application>

   
    
    
    
    
    
  








Related examples in the same category

1.Using showRoot property to start the display from the second levelUsing showRoot property to start the display from the second level
2.Get selected item from TreeGet selected item from Tree
3.Get selected label for Tree itemGet selected label for Tree item
4.Open nodes in the Tree control based on the values of query string parametersOpen nodes in the Tree control based on the values of query string parameters
5.Add icon fields to TreeAdd icon fields to Tree
6.Using the setItemIcon() method for Tree controlUsing the setItemIcon() method for Tree control
7.depth color for Tree styledepth color for Tree style
8.alternatingItemColors for Tree stylealternatingItemColors for Tree style
9.Set depthColors for Tree control through xml attributeSet depthColors for Tree control through xml attribute
10.set alternatingItemColors for Tree control through xml attributeset alternatingItemColors for Tree control through xml attribute
11.Use Label for Tree labelFieldUse Label for Tree labelField
12.Drag and drop on a TreeDrag and drop on a Tree
13.Search a TreeSearch a Tree
14.Expand tree nodeExpand tree node
15.Drill Into TreeDrill Into Tree
16.Specify an icon displayed with each Tree leaf when you populate it by using XMLSpecify an icon displayed with each Tree leaf when you populate it by using XML
17.Tree Item IconTree Item Icon
18.Tree Open NodeTree Open Node
19.Use style to set tree node open durationUse style to set tree node open duration
20.Define Arrays of colors for properties of the Tree type selectorDefine Arrays of colors for properties of the Tree type selector
21.Use groupIconFunction to display a custom icon for navigation tree top level nodeUse groupIconFunction to display a custom icon for navigation tree top level node
22.Creating a separate column for the navigation treeCreating a separate column for the navigation tree