So, it seems, that there isn’t anywhere in the world wide web and especially in the Adobe Flex components collection, a component which will let you choose the date and time. Horrible!
Here I made two subclasses, which will do that for you. It was nearly impossible to create this, because every function that was needed to override was set by them to private. … and they have this wonderful scrubTimeValue function, which kills your time of the whole date, every time you want to actualize your data.
With lot’s of fudging, finally, there came up a working overwritten class!
As you can see in this example, it works properly in Datagrids and keeps the data-binding alive. I hope this class works for you as well as for me!
*** UPDATE ***
Due to some bugs when using this component outside of a datagrid, i recreated this component. So check it out in the example. Everything is working properly!

Hello!
This is very useful example. But I have noticed, that CollectionEvent.COLLECTION_CHANGE event throws 2 times. Why could it be?
The CollectionEvent.COLLECTION_CHANGE is thrown by the ArrayCollection, everytime the data in the ArrayCollection changes.
This means, with every addItem operation it will dispatch an COLLECTION_CHANGE Event.
But I’ve added only 1 record, why event has been thrown 2 times?
As I understand, 1 time is “add” event, when an item is added and 2 time is when DataGrid is updating it’s length property (event.kind == “update”).
Try it with tracing the event itself. Then you will see that there are two kinds of collection change events.
collection change[CollectionEvent kind="add" location=0 oldLocation=-1 type="collectionChange" bubbles=false cancelable=false eventPhase=2]
collection change[CollectionEvent kind="update" location=-1 oldLocation=-1 type="collectionChange" bubbles=false cancelable=false eventPhase=2]
That means, for each addItem operation you will receive an collection change event that an item has been added, and that the whole ArrayCollection has been updated.
Hey, what’s the license on your code? Would you say it’s MIT licensed or similar (that would be best
? Sorry for the formality, just this project I’m working on wants to have everything in order.
Nevermind really, these aren’t going to work for my use anyway – they’re pretty buggy when used outside a grid, FYI.
as you can see there isn’t any license anyway – but of course you can feel free to use this code at your purpose – like in the MIT license.
Can you tell me some of your bugs? I tried this component without grids, but didn’t found any bugs.
I’ll fix them, just tell me which bugs …
Hi! Nice component but as pointed out by Tristan it has some issues:
- no default width (resulting in a too small component when no width is specified)
- the initial date value bound to the component isn’t displayed in the component
- just opening the popup results in the clearing of the selectedDate property (a change event fires and at that time the selectedDate property is null)
I really hope you can fix these issues because apart from them this is a much needed component that Adobe should have provided years ago…
This is the test application I used:
I’m on it!
Looks like you are a real professional. Did you study about the subject? lol
Okay. I’m sorry for this late fix.
But finally i made it to work. I hope, that it works for you as properly as for me!
And thank you again for bug reporting!
Great article! It’s worked for me. Thanks a lot
Hey, great component. This should have been provided by Adobe a long time ago. One more bug though, if I use the component as an itemEditor instead of itemRenderer it closes the DateTimeChooser whenever I try to click inside the timefield.
Any ideas? Thanks!
Hey, I am not sure if you had fixed this issue but binding an initial date value is not working for me. I traced through the selectedDate set function and it seems to be setting _cSelectedDate correctly but when the component appears it is empty.
I really like this component and besides that it is working great.
As I type this I hacked a solution, but this isn’t a good fix I would really suggest rather than last resort. In the labelDateTime function I added an else if clause checking if _cSelectedDate is not null, then displaying the output of it.
HI, very good component, ive been locking for something like that for a long time…
but how can i use it as an itemEditor in a DataGrid?
ive debuged it and i think its an focus problem but i have no idea how to solve that…
if someone has an idea please leave an reply too…
have a nice day
BPS
@David: the whole component is a bunch of botched code, because adobe put all functions i needed in private state. they really wanted to prevent this component from being changed. That means, your “bugfix” is the right way
. Thanks for posting
@BPS: You’re right, it’s kind of a focus problem which i recently could not fix due to time issues in my studies. The good point is, you don’t have to use it as an itemEditor, because this component updates its data value as an itemRenderer too. But, i’m looking forward to fix this issue.
Thanks for your replies.
Hi,
)
thanks for the fast answer…(just 18 minutes
i cant use it as an itemRenderer because i have multiple values in the DG like an Date, Time, Date/Time or Text, … i have to use itemeditors because i cant set an itemrenderer for just one row afaik. If someone has an idea leave an reply
cu
hand
BPS
Hi,
thank you for this component!
I have some problem with the Date(Time)Field text property.. It should set the time too (not only the date)..
How can I solve this problem?
Peter
use the selectedDate property.
Hi,
Really thanks for your component!
Its very helpful.
I have the problem for using it when I set:
editable=”true”
It shown the string with “GMT 2005″ like string after the selected date time.
As I would like to provide function for using to “copy and paste” the string for updating. How can I truncate the string to be the same as the one showing when editable=”false”?
Thanks.
RicKi
There is a little problem in this component. There are several functions, which are in private state. I couldn’t override them.
I’m sorry, but i think you need a very nasty workaround there.
Maybe extend the component by a mouse-double_click event listener, and create put on push the own modified data in to the copy&past memory.