0 Replies Latest reply on Jan 26, 2011 4:04 PM by GabMusic7

    drawRowBackground not refreshing the ADG

    GabMusic7

      Hello everybody:

       

      I'm modifying a program that wasn't developed by me.  It uses a custom AdvancedDataGrid as follows:

       

      package myComponents

      {

          import flash.display.Sprite;

          import mx.controls.AdvancedDataGrid;

         

          public class ColorADG extends AdvancedDataGrid

          {

              public var rowColorFunction:Function;

             

              override protected function drawRowBackground(s:Sprite,

                  rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void

              {

                  if(rowColorFunction != null)

                  {

                      var item:Object;

                      if(dataIndex < dataProvider.length)

                      {

                          item = dataProvider[dataIndex];

                      }

                 

                      if(item)

                      {

                          color = rowColorFunction(item, rowIndex, dataIndex, color);

                      }

                  }

                  super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);

              }

          }

      }

       

      In the actual module, the rowColorFunction is defined as follows:

       

      private function calcRowColor(item:Object, rowIndex:int, dataIndex:int, color:uint):uint
      {
          switch(item.orderStatus) {
              case '0':
                  return color;
              case '1':
                  return 0xedfae3;
              case '2':
                  return 0xf2eef7;
              default:
                  return color;
          }
      }

      . . .

      <myComponents:ColorADG rowColorFunction="calcRowColor"

          designViewDataType="flat" dataProvider="{orders}" id="adgOrders"/>

       

      The ADG draws fine when the module is loaded, but after I add, modify or delete a row,

      the data in the component isn't refreshed and the ADG shows no results at all.

       

      I've tryed validateNow(), dataprovider.Refresh() methods, and also re-setting and

      refreshing the Array.  Nothing worked.


      I can't identify the bug, so I'd appreciate if anyone could help me fix this problem.

       

      Thank you.