欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何在Renderer中设置属性 Renderer中设置属性的方法实例

程序员文章站 2022-03-07 18:48:55
classfactory的properties妙用 1)uitextfield与label,使用label显不出来 复制代码 代码如下:package com.cit...

classfactory的properties妙用

1)uitextfield与label,使用label显不出来

复制代码 代码如下:

package com.citigroup.presentation.csa
{
    import flash.events.mouseevent;

    import mx.controls.label;
    import mx.controls.advanceddatagridclasses.advanceddatagridheaderrenderer;
    import mx.core.uitextfield;
    import mx.events.flexevent;

    public class groupheaderrenderer extends advanceddatagridheaderrenderer
    {
        public var children:array=[];
        public var expand:boolean=true;
        private var l:uitextfield;
        public function groupheaderrenderer()
        {
            super();
            l=new uitextfield();
            l.text="[-]";
            l.addeventlistener(mouseevent.click,toggle);
                    addchild(l);
            this.addeventlistener(flexevent.creation_complete,init);

        }
        private function init(event:flexevent):void{
            if(expand){
                l.text="[-]";
            }else{
                l.text="[+]";
                togglechildren(false);
            }
            this.removeeventlistener(flexevent.creation_complete,init);
        }
        override public function set data(value:object):void{
            super.data = value;
            this.setstyle("color","0xf9f088");
            this.setstyle("fontweight","bold");
            this.setstyle("textalign","left");
        }
        override protected function updatedisplaylist(unscaledwidth:number, unscaledheight:number):void{
                    super.updatedisplaylist(unscaledwidth,unscaledheight);
            label.x=0;
            l.x=label.x+label.width;
                    l.y=label.y;
        }

        private function toggle(event:mouseevent):void{
            if(l.text=="[+]"){
                l.text="[-]";
                togglechildren(true);
            }else{
                l.text="[+]";
                togglechildren(false);
            }
        }
        private function togglechildren(visible:boolean):void{
            if(children.length<=1) return;
            for(var i:int=1;i<children.length;i++){
                children[i].visible=visible;
            }
        }
    }


public function genadgcolumn(headertext:string,datafield:string,width:number=100):advanceddatagridcolumn{
                var col:advanceddatagridcolumn=new advanceddatagridcolumn();
                col.headertext=headertext;
                col.datafield=datafield;
                col.width=width;
                return col;
            }
            public function genadgcolumngroup(headertext:string,datafield:string,children:array,expand:boolean=true):advanceddatagridcolumngroup{
                var group:advanceddatagridcolumngroup=new advanceddatagridcolumngroup();
                group.headertext=headertext;
                group.datafield=datafield;
                <span style="color:#ff0000;">var cf:classfactory=new classfactory(groupheaderrenderer);
                cf.properties ={'children':children,'expand':expand};
                group.headerrenderer=cf;                 
                group.children=children;
                return group;
            }