0 Replies Latest reply on Aug 31, 2007 8:36 AM by Robert Hirst

    Binding Date properties

    Robert Hirst Level 1
      Just wondering if anyone has a tips on getting fields bound to the individual components of a Date object.

      I want to have a DateField also bound to a Date object, but also have individual fields to alter the hours, minutes, seconds, preferably bound to those properties of the selected date on the Date object. I know that selectedDate is bindable, but it would seem that the properties on the Date object itself are not.

      I am operating on a value object which maps to a database table through the SQLAssembler, so I don't want separate fields for the time components, since I will then have to have some mechanism to combine these into a single date object and pass that back to the transfer object when saving.

      What I want is something along these lines:

      <mx:DateField id="date1" selectedDate="{dateobject.date}" width="250"/>

      <mx:NumericStepper value="{date1.selectedDate.hours}" id="hours" minimum="0" maximum="23"/>

      <mx:NumericStepper value="{date1.selectedDate.minutes}" id="minutes" minimum="0" maximum="59"/>
      <mx:NumericStepper value="{date1.selectedDate.seconds}" id="seconds" minimum="0" maximum="59"/>

      I'm thinking of subclassing the DateField object to have three Bindable properties for the time components with the event firing trick to make sure that the bound values change when selectedDate is altered, and vice versa.

      If anyone has a simpler way to achieve this, I'd be very grateful for your help.

      Thanks,

      Robert