Get values from Flex Datagrid

The below example shows you how to retrieve values from datagrid on click of the Button embedded in Datagrid.

<?xml version=”1.0″ ?>
<Feature>Search Engine / Mail / Social Media</Feature>
<Feature>Search Engine / Mail</Feature>
<Feature>Search Engine / Mail</Feature>


<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”” layout=”absolute” creationComplete=”onCreate(event)”>
<mx:Script> <![CDATA[
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
private function openXMLValues(e:Event):void
var XMLConv:XMLList=new XMLList(
var XMLL:XMLListCollection=new XMLListCollection(XMLConv.item)
private function onCreate(e:Event):void
var XMLLoader:URLLoader=new URLLoader(new URLRequest(“c:\\CompanyDetails.xml”))
XMLLoader.addEventListener(Event.COMPLETE,openXMLValues) }
public function CallB(e:Event):void
{ var col:DataGridColumn = DG.columns[0];  //Access to the first(0) Column[col.dataField]); }  // Retrieving clicked row and the first column value.
<mx:DataGrid x=”21″ y=”25″ width=”388″ height=”220″ id=”DG”>
<mx:DataGridColumn dataField=”Company” />
<mx:DataGridColumn dataField=”Feature” />
<mx:DataGridColumn itemRenderer=”{ButtonRen}” />
<mx:Component id=”ButtonRen”>
<mx:Button label=”Generate” click=”outerDocument.CallB(event)”>


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.