1 Reply Latest reply on May 26, 2009 5:14 AM by _Natasha_

    datagrid problem

    thesteelmam

      hi all

      how r u

      how can i update rows colors in datagrid while scrolling ?

      i use this code for coloring rows

      package Models{
      
           import flash.display.Graphics;
           import flash.display.Shape;
           import flash.display.Sprite;
           
           import mx.collections.ArrayCollection;
           import mx.controls.DataGrid;
           import mx.core.FlexShape;
           import mx.events.ScrollEvent;
      
          public class cDataGrid extends DataGrid{
              private var _strongColor:uint = 0x9BCE49;
              private var _fadedColor:uint = 0xC9FDC8;
      
                public function cDataGrid()
                {
                     super()
                }
                
              override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number,height:Number,color:uint,dataIndex:int):void {
                  var background:Shape;
                  if (rowIndex < s.numChildren){
                      background = Shape(s.getChildAt(rowIndex));
                  }
                  else{
                      background = new FlexShape();
                      background.name = "background";
                      s.addChild(background);
                  }
                  background.y = y;
                  try{
                       if((dataProvider as ArrayCollection).getItemAt(rowIndex,0).status==0)  
                       {  
                           color = 0xffffff;  
                       } 
                       else if((dataProvider as ArrayCollection).getItemAt(rowIndex,0).status==1)  
                       {  
                           color = 0xdf8b41;  
                       } 
                       else if((dataProvider as ArrayCollection).getItemAt(rowIndex,0).status==2)  
                       {  
                           color = 0xa9a79f;  
                       } 
                           else if((dataProvider as ArrayCollection).getItemAt(rowIndex,0).status==3)  
                       {  
                           color = 0x00ff00;
                       }
                  //color == 0xFFFFFF ? color = _fadedColor : color = _strongColor;
                  
                  var graphics:Graphics = background.graphics;
                  graphics.clear();
                  graphics.beginFill(color);
                  graphics.drawRect(0, 0, width, height);
                  graphics.endFill();
                  }
                  catch(err:Error){
                       
                  }
              }
              
              
          }
      }
      
      

      any help ?

      thanx in advance