0 Replies Latest reply on Jun 8, 2009 12:59 PM by Zolotoj

    DataGrid HeaderRenderer

    Zolotoj Level 3

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      package

       

       

      modulecode

      {

       

       

      import

      flash.events.Event;

       

       

      import

      flash.system.*;

       

       

       

      import

      mx.containers.VBox;

       

       

      import

      mx.controls.Image;

       

       

      import

      mx.controls.listClasses.BaseListData;

       

       

      import

      mx.events.DynamicEvent;

      [

       

      Event(name="addEvent", type="mx.events.DynamicEvent"

      )]

       

       

      public class newSalesAccountHeaderGrid extends

      VBox

      {

       

       

      private var

      _listData:BaseListData;

       

       

      public function

      newSalesAccountHeaderGrid()

      {

       

       

      super

      ();

      }

       

       

      override protected function createChildren() :

      void

      {

       

       

      if (deleteIcon == null

      )

      {

       

       

      var deleteIcon:Image = new

      Image();

      deleteIcon.buttonMode =

       

      true

      ;

      deleteIcon.useHandCursor =

       

      true

      ;

      deleteIcon.toolTip =

       

      "Add Account"

      ;

      deleteIcon.addEventListener(

       

      "click"

      , onAddAccountClick);

      Security.allowDomain (

       

      "*"

      );

      deleteIcon.source =

       

      "D:/projects/sfcs/assets/plus.gif"

      ;

      addChild(deleteIcon);

      validateNow();

      }

      }

       

       

      protected function onAddAccountClick(event:Event):

      void

      {

      event.currentTarget.enabled =

      false;

       

       

      var dynEvent:DynamicEvent = new DynamicEvent("addEvent", true

      );

       

       

       

       

       

       

       

      When the user clicks on an icon I am making it disabled.

       

      Here how I am listening to addEvent in another mxml:

       

       

      accounts.addEventListener(

      "addEvent", onAddAccountEvent, false, 0, true);

       

       

      private

       

       

      function onAddAccountEvent(event:DynamicEvent):

      void

      {

      accounts.dataProvider.addItem(accounts.dataProvider[0]);

      accounts.scrollToIndex(accounts.dataProvider.length);

      accounts.selectedIndex = accounts.dataProvider.length;

      accounts.selectedItem.ccompany =

      "";

      accounts.selectedItem.ccustno =

      "";

      accounts.columns[0].editable =

      true;

      accounts.editedItemPosition = {columnIndex:0, rowIndex:accounts.selectedIndex};

      }

       

       

       

       

       

      As soon as accounts.dataProvider.addItem(accounts.dataProvider[0]); executes

      my icon becomes enabled. Can someone help me to understand why?

       

      Thanks