1

I have a <lightning:datatable> in which I have a rowAction which triggers and shows an edit record page (in a modal), as follows:

HTML

<lightning-datatable 
        columns={columns}
        data={data}
        key-field="Id"
        onrowaction={handleRowAction}>

</lightning-datatable>

Javascript

handleRowAction(event) {
    const actionName = event.detail.action.name;
    const row = event.detail.row;
    switch (actionName) {
        case 'edit' :
            this.navigateToRecordEditPage(row);
            break;
        default:
    }
}

navigateToRecordEditPage(row) {
    // Opens the Account record modal
    // to view a particular record.
    let { Id } = row;
    this[NavigationMixin.Navigate]({
        type: 'standard__recordPage',
        attributes: {
           recordId: Id,
           actionName: 'edit'
        }
    });
}

Is there a way for me to handle the save on the edit record modal, in order for me to trigger an update on the table?

Additional info: https://developer.salesforce.com/docs/component-library/bundle/force:recordSaveSuccess/documentation ---> This is probably what I'm looking for but in Aura, but it's not supported according to this table ---> https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.migrate_events

1 Answer 1

4

Hi,
i had this same problem but i ended up creating a custom lwc for the update. Like this:

handleRowAction(event) {
    const actionName = event.detail.action.name;
    const row = event.detail.row;
    switch (actionName) {
        case 'edit' :
            this.template.querySelector('c-edit-component').openModalEdit(row.Id);
            break;
        default:
    }
}

here openModalEdit is a public method in the lwc editComponent.

<template>
    <lightning-datatable 
        columns={columns}
        data={data}
        key-field="Id"
        onrowaction={handleRowAction}>
    </lightning-datatable>

    <c-edit-component></c-edit-component>
</template>

Hope that is helpful.

Thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .