tags:

views:

820

answers:

1

Hi, I have a flex data grid. It contains two column Maths Mark and English Mark. If Math Mark >English Mark for any row then it will set that particular row color as Green.Can you pls suggest me how to do that?

A: 

Hi here is your answer but in this i have used AdvancedDataGrid 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.

more at this link http://stackoverflow.com/questions/1078596/flex-advanced-datagrid-condition-row-background-color/1079276#1079276

Rahul Garg