views:

28

answers:

2
+2  Q: 

Flex 4 DateChooser

Hello.

I have an Array of days. I want those days to have a different background-color in the DateChooser component, say red.

How can I do that please?

A: 

You have to use disabledRanges and disabledColor. Here is an example on "Flex examples".

splash
But I don't want to disable them, I want them usable, just marked up. Plus there's 2 or 3 colors I want to use.
Francisc
Oops, I was asleep at the switch.
splash
No problem, thanks for trying. :)
Francisc
+2  A: 

The DateChooser isn't that easy to customise!

Something close to this will work, though you'll need to tweak it somewhat to suit what you want to do.

public class FancyDateChooser extends DateChooser {
    public var fancyStyleName : String;
    public var dayToMakeFancy : String;

    protected override createChildren() : void {
        super.createChildren();
        var dateGrid : UIComponent = mx_internal::dateGrid;
        for ( var i: int = 0; i < dateGrid.numChidren; i++ ) {
            if ( ( dateGrid.getChildAt( i ) as IUITextField ).text == dayToMakeFancy ) {
                dateGrid.getChildAt( i ).styleName = fancyStyleName;
            }
        }
    }
}
Gregor Kiddie
Thanks, Gregor. That will do. I was hoping I wouldn't have to extend the class, but it seems I can't get away without. I wonder if a custom skin will suffice though.
Francisc