a complete sample:
-------------------------------------------------------------------------------------
<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
initialize="initApp()">
    <mx:Script><![CDATA[
        import mx.controls.Alert;
        import mx.events.ListEvent;        
        
        private function initApp():void{        
            dg.addEventListener(ListEvent.ITEM_CLICK,setColumnCopy) ;
        }
                
  private function setColumnCopy(event:ListEvent):void{  
   var _selectedCol:Object = dg.columns[event.columnIndex].dataField;   
   Alert.show(dg.selectedItem[_selectedCol]);  
  }    
    ]]></mx:Script>
    <mx:XMLList id="employees">
        <employee>
            <name>Christina Coenraets</name>
            <phone>555-219-2270</phone>
            <email>[EMAIL PROTECTED]</email>
            <active>true</active>
        </employee>
        <employee>
            <name>Joanne Wall</name>
            <phone>555-219-2012</phone>
            <email>[EMAIL PROTECTED]</email>
            <active>true</active>
        </employee>
        <employee>
            <name>Maurice Smith</name>
            <phone>555-219-2012</phone>
            <email>[EMAIL PROTECTED]</email>
            <active>false</active>
        </employee>
        <employee>
            <name>Mary Jones</name>
            <phone>555-219-2000</phone>
            <email>[EMAIL PROTECTED]</email>
            <active>true</active>
        </employee>
    </mx:XMLList>
    <mx:Panel title="DataGrid Control Example" height="100%" width="100%" 
        paddingTop="10" paddingLeft="10" paddingRight="10">
        <mx:Label width="100%" color="blue"
            text="Select a row in the DataGrid control."/>
        <mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" 
dataProvider="{employees}">
            <mx:columns>
                <mx:DataGridColumn dataField="name" headerText="Name"/>
                <mx:DataGridColumn dataField="phone" headerText="Phone"/>
                <mx:DataGridColumn dataField="email" headerText="Email"/>
            </mx:columns>
        </mx:DataGrid>
        <mx:Form width="100%" height="100%">
            <mx:FormItem label="Name">
                <mx:Label text="{dg.selectedItem.name}"/>
            </mx:FormItem>
            <mx:FormItem label="Email">
                <mx:Label text="{dg.selectedItem.email}"/>
            </mx:FormItem>
            <mx:FormItem label="Phone">
                <mx:Label text="{dg.selectedItem.phone}"/>
            </mx:FormItem>
        </mx:Form>
        
    </mx:Panel>
</mx:Application> 
---------------------------------------------------------------------------------


----- Original Message ----
From: helihobby <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Tuesday, February 27, 2007 10:25:58 AM
Subject: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I 
know the row/column index

Found the solution from a guy who emailed me ... thx

This is what worked for me:

yourDataGrid. addEventListener (ListEvent. ITEM_CLICK, setColumnCopy) ;

function setColumnCopy( ){

_selectedCol = yourDataGrid. columns[event. columnIndex] .dataField;

Alert.show(yourData Grid.selectedIte m[_selectedCol] );

}

As always, Thank you for all the help and support.

<BR><A 
HREF="http://www.helihobb y.com/html/ alon_desingpatte rn.html"><FONT 
SIZE="-1" FACE="Verdana, Tahoma,Arial, Helvetica, Sans-serif" >Read my 
solution for Flex Component communication here...</FONT> </A>

<BR>Sean - <A HREF="http://www.helihobb y.com"><FONT SIZE="-1" 
FACE="Verdana, Tahoma,Arial, Helvetica, Sans-serif" >HeliHobby. com</FONT>





 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

Reply via email to