0

I have used an aura iteration to create a table and I have a picklist field inside that table which uses an aura iteration itself. The problem here is that whenever I select the value of any one of the picklists, all of the picklists show the same value. I am not able to figure out how to prevent the mirroring of values in all picklists. Pasting my code below:

<aura:iteration items="{!v.wList}" var="training" indexVar="idx">
<tr><lightning:select aura:id="industryPicklist" value="{!v.approvals}" name="industryPicklist">
                        <option value="">--None--</option>
                        <aura:iteration items="{!v.approvalList}" var="ind" indexVar="key">
                            <option text="{!ind.TDisplayName__c}" value="{!ind.TName__c}"  />
                        </aura:iteration>
                    </lightning:select>
                    </div>
                    </td>
                    <td style="border: 1px solid #ddd;padding: 8px;"><div data-record="{!idx}"><lightning:button variant="brand" label="Change Status" title="Click to transfer this training to approval list" onclick="{!c.handleClick3}" value="{!training.Name}" class="{!idx}" /></div></td>
                </tr>
            </aura:iteration>

Any help in this matter is highly appreciated!

1 Answer 1

0

Your <lightning:select> components are all bound to the same value, v.approvals:

<lightning:select aura:id="industryPicklist" value="{!v.approvals}" name="industryPicklist">

You probably meant to bind them to some value inside training, your loop variable, so that each select is bound an an attribute of the current record.

2
  • I tried binding them to a value in training variable but now the button has stopped working. I guess the value is not getting passed from component to controller. Sep 1, 2020 at 6:30
  • Thank you! Your suggestion helped! The trick was to use a field of the outer iteration variable, training. By binding the picklist value with training.TName__c, I was able to prevent mirroring of picklist values. Sep 1, 2020 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .