佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Flex 自定義DataGrid實現(xiàn)根據(jù)條目某一屬性值改變背景顏色

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

熱門標(biāo)簽:呼叫中心市場需求 檢查注冊表項 網(wǎng)站文章發(fā)布 鐵路電話系統(tǒng) 美圖手機(jī) 服務(wù)器配置 智能手機(jī) 銀行業(yè)務(wù)

自定義拓展的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中實現(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; 
}
您可能感興趣的文章:
  • Flex 獲取每月第幾周小例子
  • Flex 遍歷Object鍵和值的示例代碼
  • Flex DataGrid 偽合并單元格實現(xiàn)思路
  • Flex4 DataGrid中嵌入RadioButton實現(xiàn)思路及代碼
  • flex 遍歷Object對象內(nèi)容的實現(xiàn)代碼
  • 全面了解flex的用途

標(biāo)簽:新疆 長治 滄州 紅河 沈陽 樂山 上海 河南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Flex 自定義DataGrid實現(xiàn)根據(jù)條目某一屬性值改變背景顏色》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    清丰县| 东海县| 二手房| 澎湖县| 宁远县| 如东县| 临朐县| 铁岭市| 淅川县| 宿迁市| 嘉荫县| 贵定县| 勐海县| 南安市| 平昌县| 襄垣县| 洞口县| 手游| 延川县| 永年县| 闽侯县| 鹰潭市| 馆陶县| 红原县| 遂溪县| 曲沃县| 杂多县| 垦利县| 天峻县| 伊金霍洛旗| 肃北| 长武县| 南木林县| 嘉黎县| 静乐县| 福鼎市| 桓台县| 康马县| 华容县| 民和| 南漳县|