Flex 4 DateChooser

 ̄綄美尐妖づ 提交于 2019-12-01 08:26:06

问题


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?


回答1:


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



回答2:


Thanks for Gregor Kiddie's share. I modified Gregor Kiddie's code a bit. Let it can input multiple dates.

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



回答3:


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



来源:https://stackoverflow.com/questions/3813216/flex-4-datechooser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!