欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Flex 自定義DataGrid實(shí)現(xiàn)根據(jù)條目某一屬性值改變背景顏色

 更新時(shí)間:2014年07月27日 14:37:49   投稿:whsnow  
本節(jié)主要介紹了Flex DataGrid根據(jù)條目某一屬性值改變背景顏色,此DataGrid為自定義拓展的,需要的朋友可以參考下

自定義拓展的DataGrid(as類)代碼如下:

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);//設(shè)定顏色 
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; 
} 


} 
}

在mxml中實(shí)現(xiàn)自定義的datagrid并使用 其rowColorFunction方法

//通過(guò)比較每條記錄中dataField為act和stand的大小決定該條記錄的背景顏色 
private function setCustomColor(item:Object, color:uint):uint 
{ 
if (Number(item["act"])<Number(item["stand"])) 
{ 
return 0x7bbfea; 
} 

return color; 
}

相關(guān)文章

最新評(píng)論