I ran into the same problem about a week ago but from data bound to a label on
selection of the DG. The DGColumn has a labelFunction="dateFormat"
Selected format from the DG is in the correct format with:
private function dateFormat(item:Object, column:DataGridColumn):String
{
return myDate.format(item[column.dataField]);
}
<mx:DateFormatter id="myDate" formatString="DD-MMM-YYYY" />
Bound value was incorrectly formatting so used:
<mx:Label text="{myDate.format(dateorder)}" />
Greg
----- Original Message ----
From: Trevor.Peace <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, October 18, 2007 8:34:59 PM
Subject: [flexcoders] DateFormatter formats dates incorrectly in
AdvancedDataGridColumns
Has anyone else noticed the new formatter property failing to format dates
correctly when called from inside an AdvancedDataGridCol umn? It gets the year
totally wrong. The formatted date comes out looking like “10/17/700” when it
should be “10/17/2007”.
The column passes the date as a string (“Thu Oct 18 17:23:27 GMT-0700 2007”),
but when DateFormatter runs the string through DateFormatter. parseDateString,
it figures the timezone offset is the year, and ignores the year. Strange, eh?
Here’s some example code, simple as I could make it:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml" layout="vertical">
<mx:DateFormatter id="snafuDateFormatter" formatString="MM/DD/YYYY" />
<mx:AdvancedDataGrid dataProvider="{[{testDate:new Date}]}" width="100%"
height="100%">
<mx:columns>
<mx:AdvancedDataGrid Column dataField="testDate"
headerText="Original Date"/>
<mx:AdvancedDataGrid Column dataField="testDate"
headerText="Formatted Date" formatter="{snafuDateFormatter}"/>
</mx:columns>
</mx:AdvancedDataGri d>
</mx:Application>
Has anyone else wrestled with this yet?
Is it a real Flex bug? A known one?
Am I maybe just on crack instead?
Any help is very much appreciated…
- - - - - - - - - - - - - - - - - - - -
Trevor Peace
Admios
880 Harrison St. Suite 201
San Francisco, CA 94107
(415) 762-0736 x115
www.admios.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com