Using binding to capture the selection of a List-based component : List Selection « Components « Flex






Using binding to capture the selection of a List-based component

Using binding to capture the selection of a List-based component
           
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        import mx.events.ListEvent;
        import mx.controls.Alert;
        public var myAC:ArrayCollection = new ArrayCollection([
            {name:"A", email:"a@d.com"},
            {name:"B", email:"b@d.com"}]);

        public function handleClick(evt:ListEvent):void
        {
            Alert.show(evt.rowIndex + " / col:" + evt.columnIndex + "." + "for " + evt.currentTarget.selectedItem.name);
        }
      
    </mx:Script>
    <mx:DataGrid id="dg" width="500" height="150"
        dataProvider="{myAC}">
        <mx:columns>
            <mx:DataGridColumn dataField="name"  headerText="Contact Name" width="300" />
            <mx:DataGridColumn dataField="email" headerText="E-Mail"       width="200" />
        </mx:columns>
    </mx:DataGrid>
    <mx:Label text="selected: {dg.selectedItem.name} ({dg.selectedItem.email})" fontSize="16" />

</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Selected item and selected index from ListSelected item and selected index from List
2.Set List selected itemSet List selected item
3.Set selected index for ListSet selected index for List
4.Set selection color for ListSet selection color for List
5.Spark List Selection change listenerSpark List Selection change listener
6.Enable multiple selection for the List controlEnable multiple selection for the List control