如何在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;
}
推荐阅读
-
iOS经验之初始化方法中不该设置self.view的属性浅析
-
如何在Renderer中设置属性 Renderer中设置属性的方法实例
-
Lua中设置table为只读属性的方法详解
-
html align属性是什么含义?html中的align属性设置方法介绍
-
iOS经验之初始化方法中不该设置self.view的属性浅析
-
html align属性是什么含义?html中的align属性设置方法介绍
-
IE中document.createElement的iframe无法设置属性name的解决方法_javascript技巧
-
如何在Renderer中设置属性 Renderer中设置属性的方法实例
-
Lua中设置table为只读属性的方法详解
-
IE中document.createElement的iframe无法设置属性name的解决方法_javascript技巧