Handling a user interaction by passing the event object to a function : DataGrid Selection « Grid « Flex






Handling a user interaction by passing the event object to a function

Handling a user interaction by passing the event object to a function
         

<?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:"j@domain.com"},
            {name:"B", email:"f@domain.com"}]);

        public function handleClick(evt:ListEvent):void
        {
            Alert.show(evt.rowIndex + " / col:" + evt.columnIndex + "." + "Which is for " + evt.currentTarget.selectedItem.name);
        }
      
    </mx:Script>
    <mx:DataGrid id="dg" width="500" height="150" dataProvider="{myAC}"
        itemClick="handleClick(event)">
        <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:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Remove selected item from DataGridRemove selected item from DataGrid
2.Get selected index from DataGridGet selected index from DataGrid
3.DataGrid allows Multiple SelectionDataGrid allows Multiple Selection
4.Navigate to URL from DataGrid as selection changedNavigate to URL from DataGrid as selection changed