--- In [email protected], "Steve Moore" <[EMAIL PROTECTED]> wrote:
>
> I've got a datagrid binded to an ArrayCollection returned from a
> ColdFusion query. One of the columns is a date field that I'm using
a
> labelFunction to format in mm/dd/yyyy format. From reading various
posts
> I see that I need to code a sortCompareFunction to allow proper
sorting
> on this column. However I haven't found any code to do this. Does
anyone
> have such code? Below are the basics of my flex app.
>
>
> <mx:DataGrid x="10" id="dgSales" dataProvider="{salesResult}"
top="0"
> bottom="10">
> <mx:DataGridColumn headerText="Sale Date" labelFunction="formatDate"
> width="80"/>
>
> public function formatDate(item:Object,
column:DataGridColumn):String
> {
> if(item.saledt!=null) {
> return dateFormat.format(item.saledt);
> } else {
> return '';
> }
> }
>
>
>
> Steve Moore
> Larimer County Web Administrator
> (970) 498-5049
> [EMAIL PROTECTED]
> www.larimer.org
>
<mx:DataGridColumn headerText="Sale Date" labelFunction="formatDate">
width="80" sortCompareFunction="sortColumnNumber"/>
private function sortColumnNumber( x:Object, y:Object):int
{
if( num1 > num2 )
{
return 1;
}
else if( num1 < num2 )
{
return -1;
}
else
{
return 0;
}
}