国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Flex > 正文

Flex 自定義DataGrid實現根據條目某一屬性值改變背景顏色

2024-09-08 18:16:54
字體:
來源:轉載
供稿:網友

自定義拓展的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);//設定顏色 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中實現自定義的datagrid并使用 其rowColorFunction方法

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

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长乐市| 沿河| 津南区| 绥棱县| 武平县| 宜宾县| 加查县| 六枝特区| 淳化县| 柏乡县| 凭祥市| 固阳县| 巴青县| 连城县| 建宁县| 沙湾县| 嘉义市| 镇原县| 二连浩特市| 安图县| 兰坪| 西安市| 无棣县| 军事| 汝南县| 广宗县| 新安县| 广水市| 溆浦县| 蒲城县| 武威市| 松阳县| 仁怀市| 江阴市| 上高县| 武宁县| 天祝| 和林格尔县| 松潘县| 绍兴县| 同心县|