1 Reply Latest reply on Feb 6, 2007 1:27 PM by michael_ramirez44

    Take Input- Help

    jakelove007
      the function below formats a datagrid column (mtm). How do I make this general such that I may pass in any column, not just the column mtm?
      thank you in advance.


      package {
      import mx.controls.Text;
      import mx.formatters.CurrencyFormatter


      public class MtmItemRenderer extends Text
      {
      override public function set data(value:Object):void {
      super.data = value;
      var cf:CurrencyFormatter = new CurrencyFormatter;
      cf.currencySymbol = "$";cf.precision = 2;
      if(value!=null) {
      if (Number(value.mtm) < 0)
      {
      this.setStyle("color","red");
      } else {
      this.setStyle("color","black");
      }

      this.text = cf.format(value.mtm);
      }
      super.invalidateDisplayList();
      }
      }
      }

      thank you in advance

        • 1. Take Input- Help
          michael_ramirez44 Level 1
          You can set a Bindable property inside your ItemRenderer and Bind to it.

          /** MtmItemRenderer **/
          [Bindable]
          var dataField:String;
          ...

          /** Main Application **/
          MtmRenderer = new ClassFactory(MtmItemRenderer);
          MtmRenderer.properties = {dataField: "mtm"};
          newColumn.itemRenderer = MtmRenderer;