Apex Refresh data-table is not working on LWC. Can anyone please help me what I'm missing below.
HTML:
<div class="slds-p-top_x-large">
<lightning-datatable key-field="Id" data={data} columns={columns}
draft-values={draftValues} hide-checkbox-column="true"
resize-column-disabled="true">
</lightning-datatable>
</div>
<div class="slds-size_2-of-2">
<lightning-button type="submit" variant="brand" value="AddParent"
name="AddParent" label="Save" onclick={handleonClickParent}>
</lightning-button>
</div>
JS
import { refreshApex } from "@salesforce/apex";
@track error;
@track data;
@wire(getParentdetails, { enrollmentName: "a082w000000YUH5AAO" })
getContacts(response) {
console.log("data -->" + response);
this.wiredDataRefresh = response;
const data = response.data;
const error = response.error;
if (data) {
this.data = data;
} else if (error) {
this.error = error;
}
}
handleonClickParent() {
return refreshApex(this.wiredDataRefresh);
}
refreshData() {
return refreshApex(this.wiredDataRefresh);
}
Apex:
@AuraEnabled (cacheable = true)
public static List<Contact> getParentdetails(Id enrollmentName) {
return [select Id, Firstname, LastName, Email, Phone, Student_Relation__c
from Contact WHERE Enrollment_Name__c=:enrollmentName];
}
enrollmentName
is expecting an ID but in your sample you're putting "man"refreshData()
but doesn't look like you ever call it elsewhere in your codehandleonClickParent
is called. Edited my questions