CellColor.mxml
在DataGridColumn的itemRenderer中引用 如itemRenderer="CellColor"
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" textAlign="right" >
<mx:Script><![CDATA[
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.listClasses.BaseListData;
override public function set data(value:Object):void
{
super.data = value;
var dg:DataGrid = this.owner as DataGrid;
if(dg && data){
var gdgc:DataGridColumn =
dg.columns[listData.columnIndex] as DataGridColumn;
if(data[gdgc.dataField]> 0){
this.setStyle("color",0xCD0000);
}
if(data[gdgc.dataField] < 0){
this.setStyle("color",0x006400);
}
}
}
]]></mx:Script>
</mx:Label>
在DataGridColumn的itemRenderer中引用 如itemRenderer="CellColor"