Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色(flex布局可以自适应吗)全程干货

随心笔谈11个月前发布 admin
96 0


package czgh.components
{
import flash.display.Sprite;

import mx.controls.DataGrid;
import mx.core.UIComponent;

public class OptionalDataGrid extends DataGrid
{
private var _rowColorFunction:Function;
private var _customed:Boolean;
private var _customerColor:uint=0;
public function OptionalDataGrid()
{
super();
}

override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
{
color=0XFFFFFF;

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);
}

override protected function drawHeaderBackground(headerBG:UIComponent):void
{
headerBG.setStyle(“borderVisible”,”false”);
}

public function set rowColorFunction(rowColorFunction:Function):void
{
this._rowColorFunction=rowColorFunction;
}

public function get rowColorFunction():Function
{
return this._rowColorFunction;
}

}
}

© 版权声明

相关文章