Currently, I am using the above code to preselect the first row:
//preselect the first invoice row
setTimeout(() => this.selectedRows = this.invoiceList.map(record=>record.id));
The invoiceList
is a list of invoices displayed in my datatable (invoiceList = datatable's data)
By using this code, all the rows of my datatable were going to be preselected, however maxrowselection is 1. So only the first row is preselected. In the browser's console I get this error:
The number of keys in selectedRows for lightning:datatable exceeds the limit defined by maxRowSelection.
I don't know how to access only the first element of my list. Any thoughts?
Thank you!