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
Priya GovindasamyPriya Govindasamy 

Preselect checkbox

I have a lightning datatable with checkbox. I want to preselect checkbox on load/refresh of the component. I was able to set selectedRows with id. Console log shows before and after the ids are set. However on UI the checbox does not appear. How can I show the checkbox with the checked mark?

some thing like this - 

var idVal = ['a013D000003R0EQQA0'];
component.set("v.selectedRows", idVal);
console.log( ' Before ', component.get("v.selectedRows") );
        component.set("v.selectedRows", idVal);
        console.log( ' After ', component.get("v.selectedRows") );
sowmya Inturi 9sowmya Inturi 9
Hi Priya,
Try using this:
<ui:inputCheckbox aura:id="checkbox" label="Select?" change="{!c.onCheck}" value="true"/> in the component.


Thanks,
Sowmya.
Priya GovindasamyPriya Govindasamy
Hi Sowmya,

Thanks for the reply. I am using lightning datatable which comes with checkbox. I have not coded anything for checkbox.

Priya
Meghna Vijay 7Meghna Vijay 7
Hi Priya,
I had the same problem and i tried the same method and every possible way but it didn't work, so used this link to do it :-
https://www.biswajeetsamal.com/blog/lightning-table-with-multiple-checkbox-select-options/

Thanks
 
Priya GovindasamyPriya Govindasamy
Hi Meghna,

Thanks for your reply. I have raised the case with salesforce. Will post the resolution.

Thanks,
Priya