1 Reply Latest reply on Apr 8, 2008 7:18 AM by SlowPossiblyStupid

    Dateformatter in Advanced Datagrid

    SlowPossiblyStupid
      Hi All,

      I am trying to format a date field in the advanced datagrid but it displays the date incorrectly. It either displays 100 or 2000.

      The data comes from a webservice and I convert the data from the webservice into an arraycollection and each item in the arraycollection is of a custom type. One of the fields in the custom type is a date.

      The data shows in the advanced datagrid correctly but in a very long form eg "Wed Mar 19 15:55:26 GMT+0000 2008".

      I want to format the date so that it just displays the year, month and date so would be in the format DDD/MMM/YYYY. To do that I am using a dateFormatter within the Advanced Datagrid column in the following way:

      <mx:AdvancedDataGridColumn headerText='PriceDate' width='240' dataField='priceDate'>
      <mx:formatter>
      <mx:DateFormatter formatString="DD/MMM/YYYY" />
      </mx:formatter>
      </mx:AdvancedDataGridColumn>


      I obviously expect to see "19/Mar/2008" but instead I get "19/Mar/2000".

      If you can solve it for me or suggest another way, it would be much appreciated.

      Best regards
        • 1. Re: Dateformatter in Advanced Datagrid
          SlowPossiblyStupid Level 1
          This was solved using the labelfunction property instead. I dont know why using a DateFormatter within the Advanceddatagridcolumn didnt work - it looks like a bug.

          But the solution is to have the datagridcolumn like:

          <mx:AdvancedDataGridColumn headerText="Price Date" dataField="priceDate" labelFunction="date_labelFunc"/>

          and have a DateFormatter on its own in the mxml as in :

          <mx:DateFormatter formatString="DD/MMM/YYYY" id="dateFormatter" />
          labelFunction="date_labelFunc"/>

          and the labelfunction should look like:

          private function date_labelFunc(item:Object, column:AdvancedDataGridColumn):String {
          return dateFormatter.format(item.priceDate);
          }