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
d.tejdeep@nicomatic.ind.tejdeep@nicomatic.in 

How to pass the value to particular row in aura:iteration

<aura:iteration items="{!v.QliList}" var="Qli" indexVar="sNo">      
               <tr>
                    <td><div class="slds-truncate">{!sNo+1}</div></td>
                    <td><div class="slds-truncate">{!Qli.Name}</div></td>
                    <td><div class="slds-truncate">{!Qli.Description__c}</div></td>
                   <td><div class="slds-truncate">{!Qli.Family__c}</div></td>
                   <td><div class="slds-truncate"><ui:inputText aura:id="dynamicResult" class="pnsuggestion" value="{!Qli.Part_number_Suggestion__c}"/></div></td>
                   <!--<td><div class="slds-truncate">{!Qli.PN_Suggestion__c}</div></td>-->
                    <td><div class="slds-truncate"></div>
                    <lightning:button type="button" onclick="{!c.UpdatePnsuggestion}"   name="CMM Tooling and Accessories" label="{!sNo}">CMM Tooling and Accessories</lightning:button>
 </td>
                </tr>
          </aura:iteration>

//JS

    UpdatePnsuggestion: function(component,event,helper){
       var va= event.getSource().get("v.name");
       var indexnumber= event.getSource().get("v.label");
      console.log(indexnumber);
        component.set("v.QliList.Part_number_Suggestion__c", va);  
    },  

I want to pass the button value to inputtext field {!Qli.Part_number_Suggestion__c}

In iteration n number of record when I click on a button it is copying the value to all records. But in my case, I would like to copy value only to the current row.
 
Ajay K DubediAjay K Dubedi
Hi,

Try following steps:
1. First define an attribute on lightning:button like tabIndex="{!sNo}".
2. Then in controller fetch its value like let tbI = e.getSource().get('v.tabIndex');
3. Now row information will be let rowValue = c.get('v.QliList')[tbI].

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com