Flex 自定義DataGrid實(shí)現(xiàn)根據(jù)條目某一屬性值改變背景顏色
更新時間: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方法
//通過比較每條記錄中dataField為act和stand的大小決定該條記錄的背景顏色
private function setCustomColor(item:Object, color:uint):uint
{
if (Number(item["act"])<Number(item["stand"]))
{
return 0x7bbfea;
}
return color;
}
相關(guān)文章
使用flex中的httpservice方法與java進(jìn)行交互
這篇文章主要介紹了使用flex中的httpservice方法與java進(jìn)行交互,需要的朋友可以參考下2014-02-02
如何在Renderer中設(shè)置屬性 Renderer中設(shè)置屬性的方法實(shí)例
如何在Renderer中設(shè)置屬性 Renderer中設(shè)置屬性的方法實(shí)例,需要的朋友可以參考一下2013-06-06
Flex中TabNavigator設(shè)置Tabs樣式思路及源碼
這篇文章主要介紹了Flex中TabNavigator如何設(shè)置Tabs樣式有哪些思路,感興趣的朋友可以看看下面的源碼2014-05-05
Flex播放器(實(shí)現(xiàn)播放、緩沖進(jìn)度條和音頻曲線顯示)
這篇文章主要介紹了Flex播放器(實(shí)現(xiàn)播放、緩沖進(jìn)度條和音頻曲線顯示),需要的朋友可以參考下2014-07-07
Flex中實(shí)現(xiàn)對一個text渲染不同的字體顏色示例
本文為大家詳細(xì)介紹下Flex中如何實(shí)現(xiàn)對一個text渲染不同的字體顏色,具體的實(shí)現(xiàn)思路及代碼如下,有興趣的朋友可以參考下哈,希望對大家有所幫助2013-07-07
Flex設(shè)置LinkButton的背景色有思路有源碼
Flex中沒有設(shè)置LinkButton的背景色的屬性,可以直接通過調(diào)用樣式方法畫出LinkButton的背景色2014-08-08

