Flex: How to make DateChooser show selectedDate

1k Views Asked by At

I got a Problem with my DateChooser. When clicking the control directly it highlights the date as it should. When selecting the date programmatically it won't show.

var date:Date = notification.getBody() as Date;
_view.dcMiniCalendar.selectedDate = date;

trace tells me, that date and _view.dcMiniCalendar.selectedDate carry the correct values.

I already tried to use _view.dcMiniCalendar.invalidateDisplayList() (and some other invalidate functions as well) but neither with nor without them I get that date to be shown selected in the control.

thx in advance. x_mtd

1

There are 1 best solutions below

3
Ranhiru Jude Cooray On BEST ANSWER

Are you sure that notification.getBody() returns a valid date?

Mine works just fine.

<mx:DateChooser id="dateChooser" />

<s:Button click="button1_clickHandler(event)" />

protected function button1_clickHandler(event:MouseEvent):void
{
    var myDate:Date = new Date(2012, 11, 21);
    dateChooser.selectedDate = myDate;
}

What is the return type of notification.getBody() ? If it is a string, parse it using Date.parse()