0 Replies Latest reply on Jun 9, 2009 7:42 AM by Zolotoj

    Disable column's header

    Zolotoj Level 3

      I have a custom header renderer for one of datagrid columns. I want when I click on it to disable the header.

      Here is my code:

      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

      {

      enabled =

      false;

       

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

      dynEvent.data = data;

      dispatchEvent(dynEvent);

      }

      }

      }

       

       

       

      The header will become disable, but because of the code that runs in addEvent it wil get enabled right away.

       

       

      accounts.addEventListener(

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

      private

       

       

      function onAddAccountEvent(event:DynamicEvent):

      void

      {

       

      var newAccount:XML = XML(accounts.dataProvider[0]).copy();

      newAccount.ccompany =

      "";

      newAccount.ccustno =

      "";

       

      accounts.dataProvider.addItemAt(newAccount, accounts.dataProvider.length); // this will cause the header become enabled.

       

      accounts.scrollToIndex(accounts.dataProvider.length - 1);

       

      accounts.selectedIndex = accounts.dataProvider.length - 1;

       

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

      }

      Any idea why it works that way?

       

      Thanks