Flex Advanced Datagrid Condition Row Background Color

回眸只為那壹抹淺笑 提交于 2019-12-01 07:15:30

问题


I am trying to set the row background color for the advanced data grid control in Flex 3. Does anyone know if this is possible using a style function. Currently my style function looks like:

public function myStyleFunc(data:Object, col:AdvancedDataGridColumn):Object 
         {
            if (data["status"] == "PRICING") 
                return {color:0xFF0000 , fontWeight:"bold" , backgroundColor:0xFF0000}; 


            // Return null if the Artist name does not match.
            return null;     
         }      

However the background color does not change.

I have heard on the grape vine that I may need to override some methods to enable the background color property.

Any help would be appreciated .

Regards Karl


回答1:


I have done some thing like that but in my case color was also coming from data also but it will help you. You have to override the Datagrid and override drawRowBackground method

public class CustomDataGrid extends AdvancedDataGrid
    {   

        protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void{
              var XMLdata:XML=rowNumberToData(dataIndex) as XML;               
              if(XMLdata!=null){          
                        if(XMLdata.attribute(Constants.col) != undefined && XMLdata.attribute(Constants.col) != ""){
                            color=XMLdata.attribute(Constants.col);         
                        }else{
                            color=0xFFFFFF;
                        }                            
              }               
              super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);         
        }           
    }

By this you can get any data from the row and according to it give the color.



来源:https://stackoverflow.com/questions/1078596/flex-advanced-datagrid-condition-row-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!