package org.lxh
{
import flash.display.Sprite;
import mx.controls.DataGrid;
public class SpecialDataGrid extends DataGrid
{
private var _rowColorFunction:Function; //用于在外部能通过指定一个方法 去实现改变列的背景色
public function SpecialDataGrid()
{
super();
}
public function set rowColorFunction(f:Function):void
{
this._rowColorFunction=f;
}
public function get rowColorFunction():Function
{
return this._rowColorFunction;
}
//复写该方法
override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number, height:Number, color:uint, dataIndex:int):void
{
if( this.rowColorFunction !=null ){
if( dataIndex < this.dataProvider.length ){
var item:Object=this.dataProvider.getItemAt(dataIndex);
color=this.rowColorFunction.call(this, item, color);
}
}
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
}
}