You need to sign in to do that
Don't have an account?

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.
<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.
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