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
VRK1VRK1 

lighting:dataTable not working for when select more than one checkbox values in salesforce

 <aura:registerEvent name="oSelectedRecordEvent" type="c:skillCompEvent"/>
 <aura:attribute name="selection" type="List" />

  <lightning:datatable keyField="id"
                                     data="{!v.skillList}"
                                     columns="{!v.skillColumns}"
                                     onrowselection="{! c.getSelectedName }"
                                     /> 

Controller:

 getSelectedName: function (component, event,helpder) {        
         var selectedRows = event.getParam('selectedRows');
         var setRows = [];   
         for (var i = 0; i < selectedRows.length; i++){ 
             setRows.push(selectedRows[i]);
   
         var compEvent = component.getEvent("oSelectedRecordEvent");
         compEvent.setParams({
             "recordByEvent" : selectedRows[i].Id
         });  
         compEvent.fire()
        component.set("v.selection", setRows);  
            
     }

Now this code saves the only one record Even if i select more than 1 checkboxes ......

can anyone pls chck and let me know whats wrong in this code

Thanks  

SwethaSwetha (Salesforce Developers) 
HI VRK1,
Since the posted code is not complete, I am unable to replicate this behavior in my org. The process would be to 
1. get records List from apex controller
2. select the records
3. process the selected contacts

Try the code approach listed in https://www.biswajeetsamal.com/blog/lightning-table-with-multiple-checkbox-select-options/

Thanks