Flex 4 DateChooser

时间:2010-09-28 13:32:33

标签: flex flex4 highlight days datechooser

我有几天的时间。我想那些日子在DateChooser组件中有不同的背景颜色,比如红色。

我该怎么办呢?

3 个答案:

答案 0 :(得分:3)

DateChooser并不容易定制!

接近这个的东西会起作用,但你需要稍微调整一下以适合你想做的事情。

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;
            }
        }
    }
}

答案 1 :(得分:2)

感谢Gregor Kiddie的分享。我稍微修改了Gregor Kiddie的代码。让它可以输入多个日期。

public class MyDateChooser extends DateChooser
{
    public var highlightColor : Number = 0xff0000; // sample
    public var highlightDate : Array = ["10","20"]; // sample

    public function MyDateChooser()
    {
        super();
    }

    protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
        var dateGrid : UIComponent = mx_internal::dateGrid;
        for ( var i: int = 0; i < dateGrid.numChildren; i++ ) {
            if (dateGrid.getChildAt( i ) is IUITextField) {
                var textField:UITextField = dateGrid.getChildAt(i) as UITextField;
                for (var j:int = 0; j<highlightDate.length; j++) {
                    if ( textField.text == highlightDate[j] ) {
                        textField.textColor = highlightColor;
                    }
                }
            }
        }

答案 2 :(得分:0)

您必须使用disabledRangesdisabledColor。这是关于“Flex示例”的example