1 Reply Latest reply on Oct 16, 2006 10:17 AM by peterent

    date itemRenderer

    netageadv
      Hi all,
      I have a dataGrid with an arraycollection as dataProvider. In the "mydate" field I have the timestamp of the date. Want to render it in the column with a dateField (my renderer is also my editor).
      I get an error because I can't assign a Number value to a date field. Is there a way to catch the data I'm passing to the renderer before I visualize them. Suppose to catch my number and visualize new Date(number) as my value...

      Here it is the code of the renderer class:
      -------------------------------------------
      package renderers {

      import mx.controls.*;
      import mx.core.*;

      public class DataEditabile extends DateField
      {

      public function DataEditabile() {
      //
      }

      // Override the set method for the data property.
      override public function set data(value:Object):void {
      this.selectedDate = new Date(value.mydate);
      super.data = value;
      }
      }
      }
      -----------------------------------------------------

      thnks :)
      Mariano
        • 1. Re: date itemRenderer
          peterent Level 2
          Your override of the data set function looks correct IF value is not null AND value is a Number representing the number of milliseconds since Jan 1970.

          Try this: this.selectedDate = new Date( Number(value.mydate) );

          If value.mydate is a String (eg, "1170949580038") then Number(str) will parse it into a valid Number.