In my LWC, I have multi-delete functionality. I need to check the records using checkbox and press the delete button to delete. After deleting a record, the next record automatically gets checked. Ideally, all checkboxes should remain unchecked after delete is completed.
EG: Please find the screenshot below. Out of 3 records, I deleted 1st record and after it was deleted, the checkbox remained checked for the 2nd record.
How can I clear the checkbox after deletion? I checked here. It's working fine for aura but not for LWC. Is it a salesforce issue? Please guide. Thank you!
Datatable code.
<div class="slds-table_bordered slds-table_striped slds-scrollable slds-m-around_medium">
<lightning-datatable key-field="id" data={addresses} columns={columns} onrowaction={handleRowActions}>
</lightning-datatable>
</div>
Delete button code.
deleteAdd(currentRow) {
let selected = this.template.querySelector('lightning-datatable').getSelectedRows();//get selected records
let CRIdArray = [];//add all relationship IDs in array
selected.forEach(row => {
if (row.Role!=='Account') {
CRIdArray.push(row.CRId);
}
});
deleteAddress({deleteIds: CRIdArray})//delete address using apex
.then(result => {
// refreshing table data using refresh apex
return refreshApex(this.refreshTable);
})
.catch(error => { //Showing error if any
//catch errors
});
}