1 Reply Latest reply on Aug 5, 2009 9:25 AM by nikos101

    I want to have a DateField as a Renderer in a ADG.

    nikos101 Level 2

      I want to have a DateField as a Renderer in a ADG. I want the date selected to initialised to the current day and when the user selects a date, that date will be added as a attribute to the item in the dataprovider. Could some one give me a hand with the code that.

       

      I've tried the following but it doesn't really work


      package
      {
      import flash.display.DisplayObject;
      import flash.events.KeyboardEvent;
      import flash.events.MouseEvent;
      import flash.text.TextField;
      import mx.controls.DateField;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
      import mx.controls.listClasses.ListBase;

       

      /**
      *  The Renderer.
      */
      public class DateFieldRenderer extends DateField
      {

       

          public function DateFieldRenderer()
          {
              focusEnabled = false;
          }

       

           override public function set data(value:Object):void
          {
             
             
              super.data = value;
             
              if(super.data != null){
                  data.bankPremiumPaidDate = new Date
                      data.isSelected = this.selectedDate;
              }
             
         
             
          //    invalidateProperties();
          }
         
         

       

          override protected function keyDownHandler(event:KeyboardEvent):void
          {
          }

       

          override protected function keyUpHandler(event:KeyboardEvent):void
          {
          }

       

      /*     override protected function clickHandler(event:MouseEvent):void
          {
                super.clickHandler(event);
             
              if(!data.isSelected){
                  data.isSelected = true;
              }else{
                  data.isSelected = false;
              }
          } */

       

          override protected function updateDisplayList(w:Number, h:Number):void
          {
              super.updateDisplayList(w, h);

       

              if (listData is AdvancedDataGridListData)
              {
                  var n:int = numChildren;
                  for (var i:int = 0; i < n; i++)
                  {
                      var c:DisplayObject = getChildAt(i);
                      if (!(c is TextField))
                      {
                          c.x = (w - c.width) / 2;
                          c.y = 0;
                      }
                  }
              }
          }

       

      }

       

      }

        • 1. Re: I want to have a DateField as a Renderer in a ADG.
          nikos101 Level 2

          Sorry that code was a bit confusing,  heres a simple version I tried:

           

          package
          {
              import flash.display.DisplayObject;
              import flash.events.KeyboardEvent;
              import flash.events.MouseEvent;
              import flash.text.TextField;
              import mx.controls.DateField;
              import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
              import mx.controls.listClasses.ListBase;

           

              /**
               *  The Renderer.
               */
              public class DateFieldRenderer extends DateField
              {

           

                  public function DateFieldRenderer()
                  {
                      this.textInputStyleName="white";
                  }
              }
          }

           

          It doesn't like the line:

           

                    this.textInputStyleName="white";

           

          not sure why, that attribute is recognised in mxml code.

           

          Any ideas how I can set up this property in the above actionscript code?