1 Reply Latest reply on Dec 21, 2009 12:12 AM by danny_run

    Need to set background color of AdvandedDataGrid Rows !... (Almost there !)

    acoquinar

      I made a subclass to implement drawRowBackground but i can't get an instance of the data assigned to the particular row... I just need to know how to use the hierarchicalData dataProvider class to do this. (Data comes from an XMLList structure.)

       

              protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void{
                     //var XMLdata:XMLList=rowNumberToData(dataIndex) as XMLList;
                     var dp:HierarchicalData = dataProvider as HierarchicalData;
                     dp. ?????                     
                     if(XMLdata!=null){                  
                          if(XMLdata.data.attribute("failed") != undefined && XMLdata.data.attribute("failed") == "1"){
                                   color=0xFF0000;             
                          }
                                                                     
                     }                       
                     super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);              
               }
      

       

      Thanks !

        • 1. Re: Need to set background color of AdvandedDataGrid Rows !... (Almost there !)
          danny_run

          Hello.

           

          override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
                  {
                      if (dataProvider != null) {
                          var array:ArrayCollection = ArrayCollection(dataProvider);
                          if (dataIndex < array.length && array[dataIndex]['colorType']==1) {
                              color = COLOR_1;                   
                          }else
                              if(dataIndex < array.length && array[dataIndex]['colorType']==2)
                                  color = COLOR_2;
                              else
                                  if(dataIndex < array.length && array[dataIndex]['colorType']==3)
                                      color = .COLOR_3;
                                  else
                                      if(dataIndex < array.length && array[dataIndex]['colorType']==4)
                                          color = COLOR_4;
                      }   
                      super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
                  }

           

          As you can see tou can build an array from your dataprovider and then use array[index][condition_for_color_property].