flex实现DataGrid高亮显示数据功能的解决方案(flex两端对齐怎么设置)全程干货

随心笔谈1年前 (2023)发布 admin
118 0

package org.lxh 

{    

    import flash.display.Sprite; 

    import mx.controls.DataGrid; 

    public class SpecialDataGrid extends DataGrid 

    { 

        private var _rowColorFunction:Function;   //用于在外部能通过指定一个方法 去实现改变列的背景色 

        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); 

        } 

    } 

}

© 版权声明

相关文章