[flexcoders] Re: Using DateField as itemEditor for DataGrid column
Thanks much, Alex! I was trying to accomplish something similar, but wasn't having much luck getting it to work. I'm using Hot Fix 1, and, as I mentioned, it throws an exception with my example as well... when run under the debug player. Otherwise it was silent. I saw the if statement in the data setter for the DateField, noticed that there was a case for data incoming as a string, and figured it was just a matter of getting the format correct. Thank you again. You're a lifesaver. --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: What version of Flex are you using? Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) both throw exceptions with this example. DateField isn't really set up to handle XML when it is an item renderer. I sort of got it working like this: mx:DataGridColumn headerText=Date dataField=date width=100 editable=true editorDataField=selectedDate rendererIsEditor=true mx:itemRenderer mx:Component mx:DateField mx:Script ![CDATA[ import mx.controls.listClasses.BaseListData; import mx.controls.dataGridClasses.DataGridListData; // block the underlying DateFields listData so it // doesn't think it is in a DataGrid private var _ld:BaseListData; override public function get listData():BaseListData { return _ld; } override public function set listData(value:BaseListData):void { _ld = value; } private var _dd:Object; override public function get data():Object { return _dd; } override public function set data(value:Object):void { _dd = value; if (_ld _ld is DataGridListData) { var s:String = value[DataGridListData(_ld).dataField].toString(); trace(s); super.data = new Date(Date.parse(s)); } } ]] /mx:Script /mx:DateField /mx:Component /mx:itemRenderer /mx:DataGridColumn Note that the first date in your example is not a valid format for Date.parse(). HTH, -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Tuesday, December 04, 2007 9:42 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application
[flexcoders] Re: Using DateField as itemEditor for DataGrid column
Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) Why is that? We're still using HF1 at work because we've not had time to do regression testing on all of our WebService operations. I suppose its a good thing too, considering all the changes in Flex 3 would require us to test yet again. Ben --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: What version of Flex are you using? Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) both throw exceptions with this example. DateField isn't really set up to handle XML when it is an item renderer. I sort of got it working like this: mx:DataGridColumn headerText=Date dataField=date width=100 editable=true editorDataField=selectedDate rendererIsEditor=true mx:itemRenderer mx:Component mx:DateField mx:Script ![CDATA[ import mx.controls.listClasses.BaseListData; import mx.controls.dataGridClasses.DataGridListData; // block the underlying DateFields listData so it // doesn't think it is in a DataGrid private var _ld:BaseListData; override public function get listData():BaseListData { return _ld; } override public function set listData(value:BaseListData):void { _ld = value; } private var _dd:Object; override public function get data():Object { return _dd; } override public function set data(value:Object):void { _dd = value; if (_ld _ld is DataGridListData) { var s:String = value[DataGridListData(_ld).dataField].toString(); trace(s); super.data = new Date(Date.parse(s)); } } ]] /mx:Script /mx:DateField /mx:Component /mx:itemRenderer /mx:DataGridColumn Note that the first date in your example is not a valid format for Date.parse(). HTH, -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Tuesday, December 04, 2007 9:42 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=vertical creationComplete=init() mx:Script ![CDATA[ import
RE: [flexcoders] Re: Using DateField as itemEditor for DataGrid column
Simply because each release theoretically got better w/o degradation in other places. I know that's not totally true so a few of you are relying on older releases, but I often find myself looking at these examples on to realize they got fixed already. It would also depend on how close I am to shipping. If I'm just about ready to publish, I probably wouldn't upgrade either, but otherwise, if I saw what appeared to be an obvious problem, I would certainly at least try it on a 'latest' release. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard Sent: Sunday, December 09, 2007 5:19 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) Why is that? We're still using HF1 at work because we've not had time to do regression testing on all of our WebService operations. I suppose its a good thing too, considering all the changes in Flex 3 would require us to test yet again. Ben --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: What version of Flex are you using? Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) both throw exceptions with this example. DateField isn't really set up to handle XML when it is an item renderer. I sort of got it working like this: mx:DataGridColumn headerText=Date dataField=date width=100 editable=true editorDataField=selectedDate rendererIsEditor=true mx:itemRenderer mx:Component mx:DateField mx:Script ![CDATA[ import mx.controls.listClasses.BaseListData; import mx.controls.dataGridClasses.DataGridListData; // block the underlying DateFields listData so it // doesn't think it is in a DataGrid private var _ld:BaseListData; override public function get listData():BaseListData { return _ld; } override public function set listData(value:BaseListData):void { _ld = value; } private var _dd:Object; override public function get data():Object { return _dd; } override public function set data(value:Object):void { _dd = value; if (_ld _ld is DataGridListData) { var s:String = value[DataGridListData(_ld).dataField].toString(); trace(s); super.data = new Date(Date.parse(s)); } } ]] /mx:Script /mx:DateField /mx:Component /mx:itemRenderer /mx:DataGridColumn Note that the first date in your example is not a valid format for Date.parse(). HTH, -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of carl_steinhilber Sent: Tuesday, December 04, 2007 9:42 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00
RE: [flexcoders] Re: Using DateField as itemEditor for DataGrid column
What version of Flex are you using? Flex 3 Beta 2 and Flex 2.0.1 HotFix2 (which are the only versions you should be using) both throw exceptions with this example. DateField isn't really set up to handle XML when it is an item renderer. I sort of got it working like this: mx:DataGridColumn headerText=Date dataField=date width=100 editable=true editorDataField=selectedDate rendererIsEditor=true mx:itemRenderer mx:Component mx:DateField mx:Script ![CDATA[ import mx.controls.listClasses.BaseListData; import mx.controls.dataGridClasses.DataGridListData; // block the underlying DateFields listData so it // doesn't think it is in a DataGrid private var _ld:BaseListData; override public function get listData():BaseListData { return _ld; } override public function set listData(value:BaseListData):void { _ld = value; } private var _dd:Object; override public function get data():Object { return _dd; } override public function set data(value:Object):void { _dd = value; if (_ld _ld is DataGridListData) { var s:String = value[DataGridListData(_ld).dataField].toString(); trace(s); super.data = new Date(Date.parse(s)); } } ]] /mx:Script /mx:DateField /mx:Component /mx:itemRenderer /mx:DataGridColumn Note that the first date in your example is not a valid format for Date.parse(). HTH, -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Tuesday, December 04, 2007 9:42 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00 GMT-0800 2007/date giftThree french hens/gift /day /root; ]] /mx:Script mx:DataGrid id
[flexcoders] Re: Using DateField as itemEditor for DataGrid column
Anybody? Anybody? Various other namespaces seem to have definitions for date values, but I haven't been successful in loading up other namespaces in XML docs for Flex consumption. And I'm not convinced it would work even if I did... seems like the date value would *still* need to be in a format that Flex could understand internally, not based on some other namespace that it knows nothing about. ANY help would be appreciated. Thanks, -Carl --- In flexcoders@yahoogroups.com, carl_steinhilber [EMAIL PROTECTED] wrote: Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00 GMT-0800 2007/date giftThree french hens/gift /day /root; ]] /mx:Script mx:DataGrid id=dgOutput dataProvider={xmlChristmas} width=600 height=160 editable=true mx:columns mx:DataGridColumn headerText=Name dataField=name width=200 editable=true / mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemEditor=mx.controls.DateField editorDataField=selectedDate / !-- mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / -- mx:DataGridColumn headerText=Gift dataField=gift width=300 editable=true / /mx:columns /mx:DataGrid /mx:Application --- In flexcoders@yahoogroups.com, Alex Harui aharui@ wrote: Can you post a mini-example? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Sunday, December 02, 2007 11:43 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Using DateField as itemEditor for DataGrid column I'm having a problem using a DateField as a itemRenderer/editor for a column in a dataGrid. If I set the DateField as my itemEditor, everything works perfectly. But if I set the DateField as my itemRenderer and set rendererIsEditor to true the dataGrid renders completely blank (no data in *any* field) and locks down so *nothing* is editable. In reading posts in the archives in this group and elsewhere, folks with similar issues were told to make sure the data bound to the column is of type date. But I have two issues with that: 1) if it wasn't understood as being of type date, why would it work when the dateField was set as the itemEditor and 2) I'm loading in the dataProvider for the DataGrid as a Bindable XMLListCollection from an external XML file... and I'm not sure how I can designate in XML that the node is
RE: [flexcoders] Re: Using DateField as itemEditor for DataGrid column
I've marked your issue for further investigation, but am backlogged this week. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Thursday, December 06, 2007 10:35 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Anybody? Anybody? Various other namespaces seem to have definitions for date values, but I haven't been successful in loading up other namespaces in XML docs for Flex consumption. And I'm not convinced it would work even if I did... seems like the date value would *still* need to be in a format that Flex could understand internally, not based on some other namespace that it knows nothing about. ANY help would be appreciated. Thanks, -Carl --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , carl_steinhilber [EMAIL PROTECTED] wrote: Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00 GMT-0800 2007/date giftThree french hens/gift /day /root; ]] /mx:Script mx:DataGrid id=dgOutput dataProvider={xmlChristmas} width=600 height=160 editable=true mx:columns mx:DataGridColumn headerText=Name dataField=name width=200 editable=true / mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemEditor=mx.controls.DateField editorDataField=selectedDate / !-- mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / -- mx:DataGridColumn headerText=Gift dataField=gift width=300 editable=true / /mx:columns /mx:DataGrid /mx:Application --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: Can you post a mini-example? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of carl_steinhilber Sent: Sunday, December 02, 2007 11:43 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Using DateField as itemEditor for DataGrid column I'm having a problem using a DateField as a itemRenderer/editor for a column in a dataGrid. If I set the DateField as my itemEditor, everything works perfectly. But if I set the DateField as my itemRenderer and set rendererIsEditor to true the dataGrid renders completely blank (no data in *any* field) and locks down so *nothing* is editable. In reading posts in the archives in this group and elsewhere, folks with similar issues were told to make sure the data bound to the column is of type date. But I have two issues with that: 1) if it wasn't understood as being of type date, why would it work when the dateField was set as the itemEditor and 2) I'm loading in the dataProvider for the DataGrid as a Bindable XMLListCollection from an external XML file... and I'm not sure how I can designate in XML that the node is of type date. Anyone have any info or pointers? They'd be greatly appreciated. Thanks in advance! -Carl
[flexcoders] Re: Using DateField as itemEditor for DataGrid column
Thank you, Alex. I'll need to be patient. ;-) One other thing I found interesting, in looking at the source of the DateField from the SDK, it appears that the data setter *does* have allowances for dates as strings... so I'm not sure why it's not working... unless I'm really not formatting the date string properly. But I've tried every format I can think of. Thanks again, Alex! --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: I've marked your issue for further investigation, but am backlogged this week. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Thursday, December 06, 2007 10:35 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Using DateField as itemEditor for DataGrid column Anybody? Anybody? Various other namespaces seem to have definitions for date values, but I haven't been successful in loading up other namespaces in XML docs for Flex consumption. And I'm not convinced it would work even if I did... seems like the date value would *still* need to be in a format that Flex could understand internally, not based on some other namespace that it knows nothing about. ANY help would be appreciated. Thanks, -Carl --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , carl_steinhilber carl_steinhilber@ wrote: Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00 GMT-0800 2007/date giftThree french hens/gift /day /root; ]] /mx:Script mx:DataGrid id=dgOutput dataProvider={xmlChristmas} width=600 height=160 editable=true mx:columns mx:DataGridColumn headerText=Name dataField=name width=200 editable=true / mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemEditor=mx.controls.DateField editorDataField=selectedDate / !-- mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / -- mx:DataGridColumn headerText=Gift dataField=gift width=300 editable=true / /mx:columns /mx:DataGrid /mx:Application --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: Can you post a mini-example? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of carl_steinhilber Sent: Sunday, December 02, 2007 11:43 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Using DateField as itemEditor for DataGrid column I'm having a problem using a DateField as a itemRenderer/editor for a column in a dataGrid. If I set the DateField as my itemEditor, everything works perfectly. But if I set the DateField as my itemRenderer and set rendererIsEditor to true the dataGrid renders completely blank (no data in *any* field) and locks down so *nothing* is editable. In reading posts in the archives
[flexcoders] Re: Using DateField as itemEditor for DataGrid column
Hi Alex, Sure. (Holiday-themed) example below. :-) XML inline, of course, rather than loaded from external doc as in my final app. As is, it works (all data is shown, and clicking in the date field opens the DateField editor... there's a coercion error on click in debug, but it's silent when not in debug). Changing the date DataGridColumn to mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / prevents any data from being shown. In debug, the coercion error occurs immediately on creation... which makes perfect sense. So the issue is definitely that Flex can't parse the date from the XML node. But I'm at a loss as to how to define the date in the XML to fix the problem. Am I going to have to step through the XML and convert it to an Object, converting the date along the way? Or is there a more straight-forward solution I'm missing? Would there be a way to wrap the DateField in a custom renderer that can convert the date on the fly? ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical creationComplete=init() mx:Script ![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var xmlChristmas:XMLListCollection; private function init():void { xmlChristmas = new XMLListCollection(xmlDaysOfChristmas.day.copy()); } private var xmlDaysOfChristmas:XML = root day nameFirst Day of Christmas/name date2007-12-25T00:00:00.000-05:00/date giftPartridge in a pear tree/gift /day day nameSecond Day of Christmas/name date12/26/2007/date giftTwo turtle doves/gift /day day nameThird Day of Christmas/name dateThu Dec 27 00:00:00 GMT-0800 2007/date giftThree french hens/gift /day /root; ]] /mx:Script mx:DataGrid id=dgOutput dataProvider={xmlChristmas} width=600 height=160 editable=true mx:columns mx:DataGridColumn headerText=Name dataField=name width=200 editable=true / mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemEditor=mx.controls.DateField editorDataField=selectedDate / !-- mx:DataGridColumn headerText=Date dataField=date width=100 editable=true itemRenderer=mx.controls.DateField editorDataField=selectedDate rendererIsEditor=true / -- mx:DataGridColumn headerText=Gift dataField=gift width=300 editable=true / /mx:columns /mx:DataGrid /mx:Application --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Can you post a mini-example? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of carl_steinhilber Sent: Sunday, December 02, 2007 11:43 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Using DateField as itemEditor for DataGrid column I'm having a problem using a DateField as a itemRenderer/editor for a column in a dataGrid. If I set the DateField as my itemEditor, everything works perfectly. But if I set the DateField as my itemRenderer and set rendererIsEditor to true the dataGrid renders completely blank (no data in *any* field) and locks down so *nothing* is editable. In reading posts in the archives in this group and elsewhere, folks with similar issues were told to make sure the data bound to the column is of type date. But I have two issues with that: 1) if it wasn't understood as being of type date, why would it work when the dateField was set as the itemEditor and 2) I'm loading in the dataProvider for the DataGrid as a Bindable XMLListCollection from an external XML file... and I'm not sure how I can designate in XML that the node is of type date. Anyone have any info or pointers? They'd be greatly appreciated. Thanks in advance! -Carl