2 Replies Latest reply on Dec 21, 2011 10:28 AM by Carol L. Frampton

    <s:datagrid> and drawRowBackground

    kaissun

      hi,

       

      the drawRowBackground method is concerned with <mx:DataGrid> component.

      My goal is to migrate my flex 3.2 application to a flex 4.5 application.
      So it's necessary to use <s:DataGrid> component. But the drawRowBackground does not exist.

      Could you give me a solution to have the same features of this method ? thanks.

       

      this is the actionScript code :

       

      override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void

              {

                  if (rowIndex == 11)

                  {

                         color=00FBEAD5;

                  }

             

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

              }

       

       

       

      Thanks in advance

        • 1. Re: <s:datagrid> and drawRowBackground
          supersonicecho

          Assuming your itemRenderers support the backgroundColor property (E.G. BorderContainer), this could work:

           

          private function drawRowBackground(rowIndex, color):void

          {

               var renderer:* = dataGroup.getElementAtIndex(rowIndex);         

               renderer.setStyle("backgroundColor", color);

          }

           

          This solution sucks though.  A much better solution would be to create custom item renderers/skin states for your dataGroup.  I suggest you read up on Spark datagroups and item renderers.  It is more work to customize but you have immense freedom.

          • 2. Re: <s:datagrid> and drawRowBackground
            Carol L. Frampton Level 2

            Look at the alternatingRowColorsBackground Component in the DataGrid skin.  You can override the prepareGridVisualElement method to draw the 11th row the color you want.

             

            Carol