XMLListCollection With List : XMLList « Data Model « Flex






XMLListCollection With List

XMLListCollection With List
         
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- dpcontrols\XMLListCollectionWithList.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"
    width="550">
    <fx:Script> 
         
        import mx.collections.XMLListCollection; 
        import mx.collections.ArrayCollection; 
        /* An XML object with categorized produce. */ 
        [Bindable] 
        public var myData:XML=  <catalog> 
                <category name="Meat"> 
                <product name="Buffalo"/> 
                <product name="T Bone Steak"/> 
                <product name="Whole Chicken"/> 
                </category> 
                <category name="Vegetables"> 
                <product name="Broccoli"/> 
                <product name="Vine Ripened Tomatoes"/> 
                <product name="Yellow Peppers"/> 
                </category> 
                <category name="Fruit"> 
                <product name="Bananas"/> 
                <product name="Grapes"/> 
                <product name="Strawberries"/> 
                </category> 
                </catalog>; 
        /* An XMLListCollection representing the data for the shopping List. */ 
        [Bindable] 
        public var listDP:XMLListCollection = new XMLListCollection(new XMLList()); 
        /* Add the item selected in the Tree to the List XMLList data provider. */ 
        private function doTreeSelect():void { 
            if (prodTree.selectedItem) 
                listDP.addItem(prodTree.selectedItem.copy()); 
            } 
        /* Remove the selected in the List from the XMLList data provider. */ 
        private function doListRemove():void { 
            if (prodList.selectedItem) 
                listDP.removeItemAt(prodList.selectedIndex); 
        } 
      
    </fx:Script>
    <s:HGroup>
        <mx:Tree id="prodTree" dataProvider="{myData}" width="200"
            showRoot="false" labelField="@name" />
        <s:VGroup>
            <s:Button id="treeSelect" label="Add to List" click="doTreeSelect()" />
            <s:Button id="listRemove" label="Remove from List" click="doListRemove()" />
        </s:VGroup>
        <s:List id="prodList" dataProvider="{listDP}" width="200"
            labelField="@name" />
    </s:HGroup>
</s:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using an XMLList component to configure menu data
2.XMLListCollection component wrapped around an XMLList
3.Creating an XMLList component to drive a List componentCreating an XMLList component to drive a List component
4.Using XMLListUsing XMLList
5.Wrapping an XMLListCollection around an XMLList
6.Use an XMLListCollection objectUse an XMLListCollection object
7.Add an XMLList to an XML Object
8.Bind to an XMLList or an E4X QueryBind to an XMLList or an E4X Query
9.Filter and Sort an XMLListCollectionFilter and Sort an XMLListCollection
10.Time formatTime format