I have an lwc which has lightning-dataTable that displays the files related list for a particular case record. As part of the 'Delete" action, I am calling apex method which deletes the selected file and once it is successful I am showing Toast. But the table is not refreshed and still showing the deleted file record in the table and had to manually refresh it. Is there any mechanism to refresh after show Toast so that table gets refreshed?
1 Answer
I assume that your datatable
component gets the value from the Apex method. If so, you can refresh apex after deleting your record. It will automatically refresh the list of records in your datatable
and force it to refresh itself.
-
what if I do not use Apex? how do I refresh a component to show a new record that was created via createRecord under the uiRecordApi? Commented Jul 9, 2023 at 23:06
-
The RefreshView API is now available for LWC. I assume it works in the same way as it did with Aura components. developer.salesforce.com/docs/component-library/documentation/… Commented Jul 10, 2023 at 7:04