flex datagrid universal date format for all columns


Create a mx:dateformatter element in ur mxml file, you can modify the format strings to your need. Check the different formatting styles available.

<mx:DateFormatter id=”dateFormatter” formatString=”EEEE, MMM. D, YYYY at H:NN A”/>

for your datagrid column that you want to format, use the label function and call your function for eg getDateLabel and use the following code to format the date.

<mx:DataGrid id=”detaildg” >
<mx:columns>
<mx:DataGridColumn dataField=”EXP_DATE” labelFunction=”dateFormat”/>
</mx:columns>
</mx:DataGrid>

You also need to import

import mx.formatters.DateFormatter;
import mx.controls.dataGridClasses.DataGridColumn;

public function getDateLabel(item:Object,column:DataGridColumn):St ring
{
return dateFormatter.format(item[column.dataField]);
}

hope that helps

regards
Swadesh

One thought on “flex datagrid universal date format for all columns

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s