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

首頁 > 開發(fā) > Flex > 正文

flex實現(xiàn)DataGrid高亮顯示數(shù)據(jù)功能的解決方案

2024-09-08 18:17:01
字體:
供稿:網(wǎng)友
flex要高亮數(shù)據(jù)一般可以使用選中效果或者設置背景,選中效果只能是高亮一條,多條高亮只能設置背景來達到效果。但是原生的DataGrid根本無法達到所要的效果,目前一般就是來改寫原生的DataGrid,只需重新寫一個類來重寫drawRowBackground方法就可以了,代碼如下

復制代碼 代碼如下:


package org.lxh 
{    
    import flash.display.Sprite; 
    import mx.controls.DataGrid; 
    public class SpecialDataGrid extends DataGrid 
    { 
        private var _rowColorFunction:Function;   //用于在外部能通過指定一個方法 去實現(xiàn)改變列的背景色 
        public function SpecialDataGrid() 
        { 
            super(); 
        } 
        public function set rowColorFunction(f:Function):void 
        { 
            this._rowColorFunction = f; 
        } 
        public function get rowColorFunction():Function 
        { 
            return this._rowColorFunction; 
        } 
        //復寫該方法 
        override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number, height:Number, color:uint, dataIndex:int):void 
        { 
            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); 
        } 
    } 
}


用的時候先引入名稱空間 xmlns:control="org.lxh.*",把原來的DataGrid改成下面這樣

復制代碼 代碼如下:


<control:SpecialDataGrid   alternatingItemColors="[0xe3eaf2,0xe8f1f8]" dataProvider="{strArray}" rowColorFunction="colorFunction" doubleClick="planDataGrid_doubleClickHandler(event)" doubleClickEnabled="true"> 
                        <control:columns> 
                            <mx:DataGridColumn dataField="選擇" sortable="false" resizable="false"  showDataTips="true"> 
                                <mx:itemRenderer> 
                                    <fx:Component> 
                                        <mx:CheckBox change="outerDocument.checkChangeHandlerForPlan(event)"/> 
                                    </fx:Component> 
                                </mx:itemRenderer> 
                            </mx:DataGridColumn> 
                        <mx:DataGridColumn dataField="id" headerText="主鍵" visible="false"/> 

                        </control:columns> 
                    </control:SpecialDataGrid>


rowColorFunction屬性用來設置高亮的效果,例如那一列需要高亮,對應的function如下

復制代碼 代碼如下:

(編輯:武林網(wǎng))

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 威信县| 壶关县| 彭山县| 射阳县| 惠安县| 分宜县| 鄂托克前旗| 云梦县| 房山区| 拉萨市| 安龙县| 德江县| 叶城县| 吉木乃县| 安西县| 麦盖提县| 洪泽县| 安吉县| 鄂伦春自治旗| 汾阳市| 武山县| 拜城县| 武邑县| 信宜市| 阿拉善盟| 礼泉县| 得荣县| 织金县| 吉首市| 达州市| 长宁县| 五河县| 盱眙县| 神池县| 文登市| 衡东县| 迁安市| 临邑县| 天台县| 新昌县| 延庆县|