You need to sign in to do that
Don't have an account?
Abdul Patel
Fetch Record Id from the aura iteration in lightning component
I am trying to show an edit pop up when someone clicks on the icon shown with aura iteration. Below is my code -
<aura:iteration items="{!v.campaign.Campaign_Members__r}" var="cm">
<tr>
<td class="slds-text-align_center">
<div id="{!cm.Id}" class="{!'btn-editStatus cmId-'+cm.Id}" onclick="{!c.handleEdit}">
<lightning:icon size="x-small" iconName="utility:edit"/>
</div>
</td>
</tr>
</aura:iteration>
How should I get the Id of the record (cm.Id) in the handleEdit function in the lightning controller?
<aura:iteration items="{!v.campaign.Campaign_Members__r}" var="cm">
<tr>
<td class="slds-text-align_center">
<div id="{!cm.Id}" class="{!'btn-editStatus cmId-'+cm.Id}" onclick="{!c.handleEdit}">
<lightning:icon size="x-small" iconName="utility:edit"/>
</div>
</td>
</tr>
</aura:iteration>
How should I get the Id of the record (cm.Id) in the handleEdit function in the lightning controller?
try this.
All Answers
Please use
<aura:component implements="force:lightningQuickAction,force:hasRecordId">
and
<aura:attribute name="recordId" type="String" />
by this you can get the id of the record.
Please let me know if you still need help
thanks
try this
In the handleEdit Js
try this.