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
A GunaleA Gunale 

Using Aura how can we fetch record ids

I have a component which has a list of Account records. I just want to collect all selected records ids and pass those to Apex class.

Thank you in advance!

List of Account records
Surender reddy SalukutiSurender reddy Salukuti

Hi ,
if its lightning Datattable then you can use like below 

 <lightning:datatable  onrowselection="{! c.handleRowAction }">

  handleRowAction : function(cmp, event, helper){
        var selRows = event.getParam('selectedRows');

in selrows variable you will get all the rows 

Suraj Tripathi 47Suraj Tripathi 47
Hi  A Gunale,
You can do it like this:
            columns="{! v.columns }"
            data="{! }"
            maxRowSelection="{! v.maxRowSelection }"
            onrowselection="{! c.updateSelectedText }"/>
updateSelectedText: function (cmp, event) {
        var selectedRows = event.getParam('selectedRows');
        cmp.set('v.selectedRowsCount', selectedRows.length);

you can take reference from this:
If you find your Solution then mark this as the best answer.  
Thank you!
 Suraj Tripathi 
A GunaleA Gunale
Thank you both of you for your quick response.