You need to sign in to do that
Don't have an account?
Yogendra Jangid
Refresh LWC component on successful save of standard edit page navigation
I am using lightning datatable where there are two actions EDIT and DELETE. When I choose the EDIT option I am opening the standard edit navigation as follows.
this opens the standard modal and update the record but same is not reflected on datatable. Is there any way we can capture the save callback/event in LWC. I know we have option in aura as force:refreshView event, is there anything similar in lightning as well?
Note: I know this is possible if I use lightning-record-edit-form where I have full control on save and submit but I need this working for the standard navigatoin.
<lightning-datatable class="slds-max-medium-table_stacked" key-field="Id" data={records.records} columns={records.columns} onrowaction={handleRowAction} hide-checkbox-column=true show-row-number-column=false> </lightning-datatable>on handleRowAction I am calling following for EDIT
handleRowAction(event) { this.actionName = event.detail.action.name.toUpperCase(); const row = event.detail.row; switch (this.actionName) { case 'DELETE': this.selectedRecord = row; this.isDeleteModal = true; break; case 'EDIT': this.navigateToRecordEditPage(event, row.Id); break; default: } } navigateToRecordEditPage(event, recordId) { event.preventDefault(); this[NavigationMixin.Navigate]({ type: 'standard__recordPage', attributes: { recordId: recordId, objectApiName: this.records.relatedSobjectApiName, actionName: 'edit' } }); }
this opens the standard modal and update the record but same is not reflected on datatable. Is there any way we can capture the save callback/event in LWC. I know we have option in aura as force:refreshView event, is there anything similar in lightning as well?
Note: I know this is possible if I use lightning-record-edit-form where I have full control on save and submit but I need this working for the standard navigatoin.
All Answers
Can you try checking the blog: https://www.axiom-consulting.co/blog/how-to-refresh-lighting-web-components-in-page-builder as it seems to have an implementation that could assist you in building your component:
>> https://www.axiom-consulting.co/blog/how-to-refresh-lighting-web-components-in-page-builder
I hope this helps and in case if this comes handy can you please choose this as the best answer so that it can be useful for others in the future.
Regards,
Anutej
Any way this implementation uses aura to capture the event(force:refreshView) and if I will embed my LWC component in my custom aura implementation, I can handle this easily. What I am expecting here if there is any OOTB functionality/event available that will allow me to catch and fire my refresh logic.