[code]
package {
//格子渲染
import fl.controls.listClasses.CellRenderer;
import fl.controls.listClasses.ICellRenderer;
import flash.text.TextFormat;
import flash.display.Sprite;
public class CellStyle1 extends CellRenderer implements ICellRenderer {
public function CellStyle1():void {
super();
}
override protected function drawBackground():void {
var format:TextFormat = new TextFormat();
switch (data.status) {
case "OK" :
format.color=0xFFFFFF;
format.size=12;
//format.align = "center";
//其他属性自己设;
setStyle("textFormat",format);
break;
case "DANGER" :
format.color=0xFF0000;
format.size=12;
//format.align = "center";
//其他属性自己设;
setStyle("textFormat",format);
break;
case "WARNING":
format.color=0xFFFF00;
format.size=12;
// format.align = "center";
setStyle("textFormat",format);
break;
default :
break;
}
var cLine2:Sprite = new Sprite();
cLine2.graphics.beginFill(0x000000);
cLine2.graphics.drawRect(0, 0, 100, 100);
setStyle("upSkin", cLine2);
super.drawBackground();
}
}
}
[/code]
~~~~~~~~~~~~~~~~~~~~
[code]
package {
//标题渲染
import fl.controls.dataGridClasses.HeaderRenderer;
import flash.text.TextFormat;
import flash.display.Sprite;
public class DatagridHeaderStyle extends HeaderRenderer {
public function DatagridHeaderStyle():void {
super();
}
override protected function drawBackground():void {
var format:TextFormat = new TextFormat();
format.font = "Arial";//字体为宋体
format.bold = true;//加粗
format.size = 12;//大小为12
format.color = 0xffffff;//颜色
setStyle("textFormat",format);
var cLine2:Sprite = new Sprite();
cLine2.graphics.beginFill(0x333333);
cLine2.graphics.drawRect(0, 0, 100, 100);
setStyle("upSkin", cLine2);
super.drawBackground();
}
}
}
[/code]
使用:
[code]
dp.dataProvider = new DataProvider("数据array");
dp.setStyle("cellRenderer", CellStyle1);
dp.setStyle("headerRenderer", DatagridHeaderStyle);
dp.setSize(512,dp.rowHeight*dp.rowCount+5);
[/code]