1 Reply Latest reply on Jan 8, 2014 6:06 PM by huangxinghui

    pre select datagrid with multiple colors

    Shruthi Premchander

      how to pre select rows in a datagrid with multiple colors based on a condition?

      for eg: I have a status column.Based on the value of the status,the rows should be highlighted.



                     highlight in green;



                     highlight in red;


        • 1. Re: pre select datagrid with multiple colors
          huangxinghui Level 1

          try this, override drawRowBackground function



          public CustomDataGrid extends DataGrid
               override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number, height:Number, color:uint, dataIndex:int):void
                    var item:Object = this.dataProvider.getItemAt(dataIndex);
                    if (item.status == 'arrived') 
                         color = 0x00FF00;
                    else if (item.status == "delayed")
                         color = 0xFF0000;
                    super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);