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

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Components » List SelectionScreenshots 
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:"[email protected]"},
            {name:"B", email:"[email protected]"}]);

        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
ww___w___.j__a_v_a_2___s.___c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.