1 Reply Latest reply on Feb 3, 2009 7:23 PM by atta707

    DataGridColumn ItemRenderers - using static renderers

    AllenFlex
      I'm still relatively new to Flex. I currently have a DataGridColumn bound to an ColorRenderer as my itemRenderer. As I look at the profiling, the number of instantiated ColorRenders are >400. Is there any way for me to set the itemRender to a static ColorRenderer object?

      <mx:DataGridColumn dataField="Clearing" headerText="Clearing Cost" labelFunction="formatNumber" itemRenderer="ColorRenderer" textAlign="right" width="100" />

      package
      {
      import mx.controls.Label;
      import mx.controls.dataGridClasses.*;

      public class ColorRenderer extends Label {

      [Bindable]
      public static var Item:ColorRenderer = new ColorRenderer();

      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
      {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      if (data && listData && data[DataGridListData(listData).dataField] < 0)
      {
      setStyle("color", 0xFF0000);
      }
      else
      {
      setStyle("color", 0x009900);
      }
      }
      }

      }