I have a data table with max-row-selection="1"
attribute to show radio button. Once user select radio button for a row and save that selected record checkbox field will become true in the salesforce.
Now I want to show the selected radio button for the row for which it was checked earlier when the data table loads. How can I do this?
I have tried to set selectedRows variable with the selected record Id when data loads during connectedcallback but it doesn't get selected.
<lightning-datatable max-row-selection="1" key-field="Id" data={dummyData} columns={cols} selected-rows={selectedRows}> </lightning-datatable>
handleGetInfo() {
getInfo({recordId: this.recordId})
.then((result) => {
this.dummyData = result;
this.error = undefined;
for(let d of this.dummyData ){
if(d.checked__c){
this.selectedRows = d.Id;
console.log('handleGetInfo '+ d.Id);
}
}
})
.catch((error) => {
this.error = error;
});
}