One way to display a human readable date in a datagrid and have it be
sortable, is to use labelFunction="{convertDate}" and have the server
send over unix milliseconds. This is important if you want to be able
to properly sort the column.

A sample function looks like:

private function convertDate(item:Object, column:DataGridColumn):String {
   var myDate:Date = new Date(item.Date);
   var months:Array = new Array();
   months = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"];
   var a:Array = new Array();
   var b:Array = new Array();

   a.push(myDate.getMonth());
   a.push(myDate.getUTCDate());
   a.push(myDate.getUTCFullYear());
                        
   b.push(myDate.getUTCHours());
   b.push(myDate.getUTCMinutes());
                        
   if (b[0]<10) { b[0] = "0" + b[0] }
   if (b[1]<10) { b[1] = "0" + b[1] }
                        
   return months[parseInt(a[0])+1] +" "+ a[1] + " " + b.join(":");
}                     }


--- In flexcoders@yahoogroups.com, "markflex2007" <[EMAIL PROTECTED]>
wrote:
>
> Hi,
> 
> I have a program the read datetime fields for SQL Server and show in
> datagrid.
> 
> I do not know how to set the date format in datagrid
(mx:DataGridColumn),
> 
> Please help me.
> 
> Please let me know if you have demo link.
> 
> Thanks.
>


Reply via email to