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
Neerudu PriyankaNeerudu Priyanka 

i want to display selected check box details and edit the partcular selected record and save on click of save button got stuck at passing selected id from compoent to controller

<aura:application extends="force:slds">
    <c:MyWRAPPER/>
</aura:application>
 
<aura:component access="global" controller="AllAccount_ApexClass">
    <aura:handler name="init" value="{!this}" action="{!c.myaction}"/>
    <aura:attribute name="accounts" type="sObject[]"/>
    <aura:attribute name="isSelectAll" type="boolean" default="false"/>
    <div>
        <!--Header-->
        <lightning:layout horizontalAlign="spread" multipleRows="true">
            <lightning:layoutItem flexibility="grow" >
                <h1 class="modal-header slds-modal__header"  align="center">Accounts Detail</h1>
            </lightning:layoutItem>
        </lightning:layout>
        <!--/Header-->
        
        <table class="slds-table slds-table_bordered slds-table_resizable-cols slds-table_fixed-layout" role="grid">
            <thead>
                <tr class="slds-text-title--caps">
                    <!--Header checkBox-->
                    <th>
                        <div class="slds-m-left_medium">
                            <!--header checkbox for select all-->
                            <ui:inputCheckbox aura:id="box3" change="{!c.selectAll}"/>
                            SELECT ALL
                        </div>
                    </th>
                    <!--/Header checkBox-->
                    <th aria-sort="none"  scope="col">Account Name</th>
                    <th aria-sort="none" scope="col">Account Id</th>
                    <th aria-sort="none" scope="col">Account Phone</th>
                    <th aria-sort="none" scope="col">Account Fax</th>
                    
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.accounts}" var="acct">
                    <tr class="slds-text-title--caps">
                        <!--Body checkBox-->
                        <td>
                            <div class=" slds-m-left_x-small">
                                <ui:inputCheckbox text="{!acct.Id}" aura:id="boxPack" value="" />
                            </div>
                        </td>  
                        <!--/Body checkBox-->
                        <td class="slds-truncate">{!acct.accName}</td>
                        <td class="slds-truncate">{!acct.accId}</td>
                        <td class="slds-truncate">{!acct.Phone}</td>
                        <td class="slds-truncate">{!acct.Fax}</td>
                       
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </div>
</aura:component>
 
({
	myaction : function(c,e,h) {
		 console.log('saveData');
        h.myAction_helper(c,e,h);
    },
     selectAll: function(c,e,h) {
  //get the header checkbox value  
  var selectedHeaderCheck = e.getSource().get("v.value");
         var selectedCount ='';
         var getAllId = c.find("boxPack");
          if(! Array.isArray(getAllId)){
       if(selectedHeaderCheck == true){ 
          c.find("boxPack").set("v.value", true);
       }else{
           c.find("boxPack").set("v.value", false);
       }
     }else{
      if (selectedHeaderCheck == true) {
        for (var i = 0; i < getAllId.length; i++) {
      c.find("boxPack")[i].set("v.value", true);
            
      //call apex class get accounts method to list account for selected id...
        }
        } else {
          for (var i = 0; i < getAllId.length; i++) {
      c.find("boxPack")[i].set("v.value", false);
      // c.set("v.selectedCount", 0);
       }
       } 
     }  
 
 },
})
 
({
    myAction_helper : function(c,e,h) {
        console.log('PRIYANKA------');
        var action = c.get("c.myAction");
        action.setCallback(this, function (response) {
            if(response.getState() === 'SUCCESS') {
                var storedResponse = response.getReturnValue();
                console.log('storedResponse:');
                console.log(storedResponse);
                c.set("v.accounts",storedResponse);
                
            } else {
                console.log('ERROR');
                console.log(response.getError());
            }
        });
        $A.enqueueAction(action); 
    }
})

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Priyanka,

Greetings to you!

You can use event.getSource() to get the value of particular checkbox or button.

Please refer below lines of code:

Component:
<aura:iteration items="{!v.mydata}" var="row" indexVar="index">
                    <tr>
                        <th scope="row"><div class="slds-truncate" title="{!row.Name}">{!row.Name}</div></th>
                        <td><div class="slds-truncate" title="{!row.Phone}">{!row.Phone}</div></td>
                        <td>
                            <div >                           
                                <lightning:input type="checkbox"
                                                 label="Show"
                                                 value="{!row}"
                                                 name="{!index}"
                                                 onchange="{!c.show}"
                                               />
                            </div>
                        </td>
                    </tr>
                </aura:iteration>

Controller:
var rowRecord = event.getSource().get('v.value');

        // Id of selected row
        console.log('rowRecord--->>> ' + rowRecord.Id);

        // Value of selected row
        console.log('rowRecord--->>> ' + JSON.stringify(rowRecord));

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas