function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brian11Brian11 

datatable selectedRows not working

Hello,

For some reason selected rows on the datatable component is not working this is what I currently have. the selectedrows are being created when the component renders. my init function. I've hard coded it here thinking it would work. Any Advice?

Component
<aura:attribute name="selectedRows" type="List" default="['a020m000001Uq00AAC']"


<lightning:datatable columns="{! v.headerFields }" data="{! v.data }" keyField="Id" showRowNumberColumn="false" resizeColumnDisabled="true" selectedRows="{!v.selectedRows }" />

 
Raj VakatiRaj Vakati
When using the attribute to bind the selected rows, it simply doesn't work, however if you find the lightning:datatable and then change the selectedRows, it works properly


 
component = component.find("partnerTable");
    component.set("v.selectedRows", selectedRowsIds);

Refer this link

https://salesforce.stackexchange.com/questions/207190/lightningdatatable-preselect-rows​​​​​​​
Brian11Brian11
@Raj,

I try assigning the component to itself like your example above but it doesnt work. It actually breaks my component. Can you show me an example?

component = component.find()