4 Replies Latest reply on Mar 21, 2008 9:04 AM by Arty13

    Dispatching DataGrid Event - Not working

    Arty13
      I created my own class and within that class it has it's own DataGrid. And when I try to dispatch a HEADER_RELEASE event for that DataGrid it does not see the event listener.

      For example
      ------------------------

      var myDataGridEvent:DataGridEvent = new DataGridEvent(DataGridEvent.HEADER_RELEASE);
      myDataGridEvent.columnIndex = myColumnIndex;

      myCustomClass.dataGrid.dispatchEvent(myDataGridEvent);

      -------------------------

      I've tried to do
      myCustomClass.dataGrid.hasEventListener(DataGridEvent.HEADER_RELEASE);
      it will return false, and I do not know why it doesnt see it.

      Any help would be appreciated, thanks.

      Art
        • 1. Re: Dispatching DataGrid Event - Not working
          peterent Level 2
          You haven't assigned an event listener to that DataGrid. All you've done is dispatch an event. You'll also need to use addEventListener.
          • 2. Re: Dispatching DataGrid Event - Not working
            Arty13 Level 1
            The event listener was added during the DataGrid Constructor, are you saying I have to add it again to the DataGrid or add it to my customClass?

            Art
            • 3. Re: Dispatching DataGrid Event - Not working
              peterent Level 2
              So you have done something like this:

              var dg:DataGrid = new DataGrid();
              ...
              dg.addEventListener( DataGridEvent.HEADER_RELEASE, someHandlerFunction )

              ?
              • 4. Re: Dispatching DataGrid Event - Not working
                Arty13 Level 1
                If you look at the DataGrid class, in the constructor it is adding event listners

                -------- CODE ------------

                /**
                * Constructor.
                */
                public function DataGrid()
                {
                super();

                _columns = [];

                // pick a default row height
                setRowHeight(20);

                // Register default handlers for item editing and sorting events.

                addEventListener(DataGridEvent.ITEM_EDIT_BEGINNING,
                itemEditorItemEditBeginningHandler,
                false, EventPriority.DEFAULT_HANDLER);

                addEventListener(DataGridEvent.ITEM_EDIT_BEGIN,
                itemEditorItemEditBeginHandler,
                false, EventPriority.DEFAULT_HANDLER);

                addEventListener(DataGridEvent.ITEM_EDIT_END,
                itemEditorItemEditEndHandler,
                false, EventPriority.DEFAULT_HANDLER);

                addEventListener(DataGridEvent.HEADER_RELEASE,
                headerReleaseHandler,
                false, EventPriority.DEFAULT_HANDLER);

                addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
                }

                ------------ End Of CODE ---------------

                So I am trying to dispatch the HEADER_RELEASE event so the headerReleaseHandler function gets called (for datagrid column sorting)

                I'm still not sure why it doesnt see the event listner, so any more help is greatly appreciated.

                Thanks,

                Art