I'd subclass DateField so it can input and output strings

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of David Frankson
Sent: Friday, April 18, 2008 7:57 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] DateField as a itemEditor in a DataGrid (xml
dataProvider)

 

I'm trying to use a DateField as a cell itemEditor/itemRenderer within
an editable DataGrid that is using an xml e4x as its data provider.
Unfortunately DateField uses selectedDate as its defaultProperty and
when you pass an xml attribute into it you get cast errors because it
wants data to already be in the Date type:

 

TypeError: Error #1034: Type Coercion failed: cannot convert
[EMAIL PROTECTED] to Date.

                at mx.controls::DateField/set
data()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\DateFi
eld.as:735]

                at
mx.controls::DataGrid/http://www.adobe.com/2006/flex/mx/internal::setupR
endererFromData()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\cont
rols\DataGrid.as:1646]

                at
mx.controls::DataGrid/commitProperties()[E:\dev\3.0.x\frameworks\project
s\framework\src\mx\controls\DataGrid.as:1606]

 

 

Has anyone figured this one out already?  I thought I'd ask before I
waste too much time on it.  Here are two examples below, both throw the
TypeError.  I've also tried extending the DateField and changing the
defaultProperty, but I still get the TypeError.

 

 

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">

<mx:Script>

                <![CDATA[

                

                [Bindable] public var xml:XML = <root><record
date="1/1/2000"/><record date="1/1/2001"/></root>;

                

      ]]>

  </mx:Script>

                <mx:DataGrid x="10" y="10" dataProvider="{xml.record}">

                                <mx:columns>

                                                <mx:DataGridColumn
headerText="Date" dataField="@date"

 
editable="true" 

 
rendererIsEditor="true" 

 
itemRenderer="mx.controls.DateField"/>

                                </mx:columns>

                </mx:DataGrid>

                

</mx:Application>

 

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">

<mx:Script>

                <![CDATA[

                

                [Bindable] public var xml:XML = <root><record
date="1/1/2000"/><record date="1/1/2001"/></root>;

                

      ]]>

  </mx:Script>

                <mx:DataGrid x="10" y="10" dataProvider="{xml.record}">

                                <mx:columns>

                                                <mx:DataGridColumn
headerText="Date"

 
editable="true" 

                rendererIsEditor="true">

                <mx:itemRenderer>

                                <mx:Component>

                                    <mx:DateField selectedDate="{new
Date(Date.parse([EMAIL PROTECTED]))}"/ <mailto:[EMAIL PROTECTED]))%7d%22/> >

                                </mx:Component>

                            </mx:itemRenderer>

            </mx:DataGridColumn>    

                                </mx:columns>

                </mx:DataGrid>

                

</mx:Application>

 

 

 

 

Reply via email to