0

I have a dropdown in a table in a lightning component. Here is the code of that td.

<tbody>
<aura:iteration items="{!v.recipientList}" var="recipient">
    <tr class="slds-hint-parent" 
        id="{!recipient.rowCount}">
        <td>
            <lightning:select aura:id="{!'recCo-'+recipient.rowCount}" onchange="{!c.changedRecipContact}">
                <option selected="selected" value="None">-None-</option>
                <aura:iteration items="{!v.consList}" var="cons">
                    <option value="{!cons.id}" selected="{!(recipient.contact.Id == cons.id)}">{!cons.name}</option>
                </aura:iteration>
            </lightning:select>
        </td>
        .
        ..
        <!--Other td inputs-->
    </tr>
</aura:iteration></tbody>

Once a contact is selected, I am trying to get the aura:id using lines below

var a = event.getSource(); var selectId = a.getLocalId();

But I am getting {!'recCo-'+recipient.rowCount}, not the dynamic value. Please advice how to get the ID and < option > value in the controller. If there is any other way of getting this id like using datasets or something like that and then the option value from it, please let me know.

I have been using < select > since a lot of years but it is broken in Chrome browser so I am trying to get this done by lightning:select. Here is the link to that issue.

0

aura:id does not support merge fields. It is always a literal value. Use another field instead, such as name.

| improve this answer | |
  • @sfdxfox I am a big fan of you. I used name field and used event.getSource().get("v.name") to get the desired value. I am selecting this as Answered but Unfortunately, lightning:select also showing -none- after selecting the dropdown in Chrome browser. here is the link. Could you please help me with this. – AshSFcloud Jun 17 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.