原文地址:http://blog.youkuaiyun.com/i_chenjiahui/article/details/22393821
以前在Flex开发中用到了表格要自定义行颜色的情况。
/**
* ActionScript file
* @author chenjiahui
*/
package com.xxx.dm.module.jsjhcNew
{
import flash.display.Sprite;
import mx.controls.AdvancedDataGrid;
public class RowColorAdvancedDataGrid extends AdvancedDataGrid
{
public function RowColorAdvancedDataGrid()
{
super();
}
override protected function drawRowBackground(
s:Sprite, rowIndex:int, y:Number, height:Number,
color:uint, dataIndex:int):void
{
var item:Object;
if(dataIndex <dataProvider.length)
{
item = dataProvider[dataIndex];
if(item.error_msg != null && item.error_msg != ''){
color = 0xffcccc;
}else if(item.less_count>0){
color = 0xffe3e3;
}else if(item.error_count>0){
color = 0xffe3e3;
}else if(item.more_count>0){
color = 0xffe3e3;
}else if(item.redundant_count>0){
color = 0xf4ed73;
}else if(item.barbarism_count>0){
color = 0xf4ed73;
}
}
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
}
}