4 Replies Latest reply on Dec 13, 2010 12:51 PM by Ladislav Navrátil

    Handling custom event from HeaderRenderer of DataGrid

    Ladislav Navrátil

      Hi all,


      i have following problem:


      I have headerRenderer,where i have custom event:


           [Event(name="changeName", type="Events.ColumnEvent")]




      my class with custom event looks like this:


      package Events


           import flash.events.Event;


           public class ColumnEvent extends Event



                    public static const CHANGE_NAME:String = "changeName";

                     public static const DELETE:String = "delete";


                     public var name:String;


                     public function ColumnEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)


                          super(type, bubbles, cancelable);



                     override public function clone():Event{

                          var newEvent:ColumnEvent = new ColumnEvent(type);

                          newEvent.name = name;

                          return newEvent;






      when somethings happends in my headerRenderer, it calls this functions, which dispatch my custom event:


      protected function header_changeHandler(event:TextEvent):void{

           var columnEvent:ColumnEvent = new ColumnEvent("changeName");

           columnEvent.name = event.text;





      and finally here i set up headerRenderer and set up listener of my event:


      //create instace of class which inherit from DataGridColumn, so column is DataGridColumn data type can i say.


      var column:Column = new Column("~column"+table.columns_arr.length);

      //create class factory of headerRenderer

      var headerFactory:ClassFactory= new ClassFactory(DataHeader_DataGrid);

      //set propertie

      headerFactory.properties = {header:"My HEADER"};

      column.headerRenderer = headerFactory;

      //here i set up listener, but onHeaderChange function isnt called, when i dispatch my custom event

      column.addEventListener(ColumnEvent.CHANGE_NAME, onHeaderChange);


      table.AddColumn(column);//add new column to columns array

      table_datagrid.columns = table.columns_arr;//update array of columns to datagrid


      thank you very mutch and sorry for my english !


      Message was edited by: Ladislav Navrátil