Custom Columns in Datagrid

A DataGrid is a formatted table whose items can be edited and displayed via custom renderers.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”onCreate(event)”>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var Values:ArrayCollection=new ArrayCollection([
{Company:”Google”,Feature:”Mail / Search Engine/Social Network”},
{Company:”Yahoo”,Feature:”Mail /Search Engine”}
]);
private function onCreate(e:Event):void
{
DG.dataProvider=Values;
}
]]>
</mx:Script>
<mx:DataGrid x=”21″ y=”25″ width=”388″ height=”220″ id=”DG”>
<mx:columns>
<mx:DataGridColumn dataField=”Company”> </mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>

Output

<mx:columns> is to use the columns property of the DataGrid control and the <mx:DataGridColumn> tag to select the DataGrid columns, specify the order in which to display them, and set additional properties Each column in a DataGrid control is represented by a DataGridColumn object.

<mx:DataGrid x=”21″ y=”25″ width=”388″ height=”220″ id=”DG”>
<mx:columns>
<mx:DataGridColumn dataField=”Company”> </mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>