I have a hierarchy of components as shown below:

                 |__ c:DataGrid
                          |__ c:DataTable

I have defined a component event(DGGetGridDataEvent) as shown below:

<aura:event type="COMPONENT" description="Indicates request to change the page of the data table." access="public">

<aura:attribute name="pageNumber" type="Integer" />
<aura:attribute name="pageSize" type="Integer"/>
<aura:attribute name="columnLabel" type="String" />
<aura:attribute name="columnName" type="String" />
<aura:attribute name="sortDirection" type="String" />

The c:DGTable component registers the event as shown below:

<aura:registerEvent name="getGridDataEvent" type="c:DGGetGridDataEvent"/>

and fires the event as shown below:

var getGridDataEvent = component.getEvent("getGridDataEvent");

        'pageNumber' : pageNumber,
        'pageSize' : pageSize,
        'actionType': 'Pagination'

The c:DataGridContainer has a handler defined as shown below:

<aura:handler name="dgGetGridDataEvent" event="c:DGGetGridDataEvent" action="{!c.handleDataFetchEvent}" phase="capture"/>

and the handler definition is as shown below:

handleDataFetchEvent : function(component, event, helper){}

However, when the event is fired the handler is not invoked. What's wrong with the code i have written?

  • Any stopPropagation() calls stopping the event? – Keith C May 5 '17 at 19:49
  • @KeithC Well, i haven't done any such thing myself explicitly in my code. – Anee May 6 '17 at 17:37

I believe what you are missing (And it is not shown in the docs) but is shown in the link below. It may be a bug or, a doc error...

Handling Custom Events in the Lightning Component Framework

<c:DGTable getGridDataEvent="{!c:DGGetGridDataEvent}"/>

Related Question(s):

Lightning Components: Unable to handle an event

Event fired by a dynamically created component does not get caught

Is that you have to specify the event when creating the component

  • You won't believe me if i say there's another event which i created first(In fact that's the first event i created in my org) which works perfectly fine(as mentioned in the docs) for the same flow. When i tried creating new events i started facing this problem. So, i was curious to know what was actually happening! – Anee May 6 '17 at 18:11
  • @Anee well in one of the links Doug says it has to be done this way and since he is on the Lightning team I tend to think it is worth a shot to see if it resolves your issue. – Eric May 6 '17 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.