However, the data is not getting refreshed in the datatable using the refreshApex method, despite using a separate variable while fetching the records for the datatabledespite using a separate variable while fetching the records for the datatable.
Datatavle Datatable in lwc not getting updated using refreshAPexrefreshApex method
However, the data is not getting refreshed in the datatable using the refreshApex method, despite using a separate variable while fetching the records for the datatable.
However, the data is not getting refreshed in the datatable using the refreshApex method, despite using a separate variable while fetching the records for the datatable.
Datatavle in lwc not getting updated using refreshAPex method
I have a lwc
html file code :
<template if:true={sObjectRecordList}> <lightning-datatable key-field="Id" data={sObjectRecordList} columns={columns} onsave={handleSave} draft-values={draftValues}> </lightning-datatable> </template> Now I am fetching and updating the records in the datatable using apex class methods
/*The apex code which fetches the datatable records*/ @wire(setSObjectRecordList , { sObjectName : 'Contact', sObjectFieldList : '$sObjectFieldDetails', parentRecordId : '$recordId', parentRecordIdFieldName : 'AccountId' }) sObjectRecords({error, data }) { if (data) { this.sObjectRecordList = data; } else if (error) { this.error = error; } } /*The apex code for updating the records edited in the datatable*/ async handleSave(event) { const updatedFields = event.detail.draftValues; // Prepare the record IDs for getRecordNotifyChange() const notifyChangeIds = updatedFields.map(row => { return { "recordId": row.Id } }); // Pass edited fields to the updateContacts Apex controller await dmlOperationOnSObjectRecords({data: updatedFields}) .then(result => { this.dispatchEvent( new ShowToastEvent({ title: 'Success', message: 'Records updated', variant: 'success' }) ); // Refresh LDS cache and wires getRecordNotifyChange(notifyChangeIds); // Display fresh data in the datatable refreshApex(this.sObjectRecordList); }).catch(error => { this.dispatchEvent( new ShowToastEvent({ title: 'Error updating or refreshing records', message: error.body.message, variant: 'error' }) ); }); } My records are getting updated via the methods.
However, the data is not getting refreshed in the datatable using the refreshApex method, despite using a separate variable while fetching the records for the datatable.
lang-html