SalesforceLabs / EnhancedLightningGrid

Component that allows you to sort and filter data within the Lightning Experience. Use as a replacement for a Related List, or create a new grid that shows results from a custom query.
BSD 3-Clause "New" or "Revised" License
136 stars 96 forks source link

Understanding Actions #27

Closed ezrafischer closed 5 years ago

ezrafischer commented 5 years ago

Hi,

I'm looking for more documentation on creating custom actions in the EnhancedLightningGrid. I'm specifically trying to create a row button on an Order Line Item that lets a user edit just the quantity field on that OrderItem.

Thanks, Ezra

greier commented 5 years ago

Hi,

you need to create a custom event and triggered it using the following:

Event:

<aura:event type="APPLICATION" description="CustomEventName">
</aura:event>

Row Button, e.g.: Event: e.c:CustomEventName Payload:

{
"objectId":"#Id#",
"parentObjectId":"#parentrecordId#",
"otherStuff":"otherAttribute"
}

Custom Component placed anywhere on the page:

<aura:component description="Custom_Actions"
              implements="flexipage:availableForRecordHome,flexipage:availableForAllPageTypes,force:hasRecordId"
                access="global">
    <aura:handler event="c:CustomEventName" action="{!c.handleApplicationEvent}"/>
</aura:component>

JS Controller:

({
    handleApplicationEvent: function (cmp, event) {

        var parentObjectId = event.getParam("parentObjectId");
        var objectId = event.getParam("objectId"); 
        var otherStuff = event.getParam("otherStuff"); 

//DO STH. HERE, e.g. record form with the 2 fields you need to change and pop it open in a modal.

    }
})

hth matthias

ezrafischer commented 5 years ago

Wow -- thank you!!

tharrington commented 1 year ago

I followed this and I am receiving an error:

Error: Invalid event name - cannot identify event