6 Replies Latest reply on Dec 15, 2010 9:05 AM by JackFreudenheim

    DataGrid, error using DateField as the item editor

    cosmacol Level 1

      I'm trying to create an editable DataGrid using Flex 2.0.1. One of the columns is of Date type, so I want to use a DateField as the item editor.

      The problem is that I'm getting an error when the focus is taken away from the DateField:

      TypeError: Error #1034: Assegnazione di tipo forzata non riuscita:
      impossibile convertire "01/10/1980" in Date.
      at mx.controls::DataGrid/::itemEditorItemEditEndHandler()

      It seems that the DataGrid is trying to assign the raw string value into my data provider object.

      This is a code snippet that reproduce the problem:

      private var rows:ArrayCollection = new ArrayCollection();
      private function init():void {
      // called on creationComplete
      var testRow:PersonVO = new PersonVO();
      testRow.name = "Name";
      testRow.surname = "Surname";
      testRow.birthDate = new Date(1980, 9, 1);
      <mx:DataGrid dataProvider="{rows}" editable="true">
      <mx:DataGridColumn dataField="name"/>
      <mx:DataGridColumn dataField="surname"/>
      <mx:DataGridColumn dataField="birthDate">
      <mx:DateField formatString="DD/MM/YYYY"/>

      Do you have any idea of the cause of this behaviour?