Skip to main content
Hi All,

I am not able to get drop down values inside aura iteration when onchange method calls.

Wrapper Object attribute:

<aura:attribute name="mapobject" type="object" access="global"/>

Aura Iteration Part:

<table class="slds-table slds-table_bordered slds-table_cell-buffer" width="100%">

    <thead>

    <tr class="slds-text-title_caps">

    <th scope="col" width="15%" class="cbcolor">

    <div class="slds-truncate" title="Brand" style="color:black"><center>Brand</center></div>

    </th>

    <th scope="col" width="20%" class="cbcolor">

    <div class="slds-truncate" title="Product Description" style="color:black"><center>Product Description</center></div>

    </th>

    </tr>

    </thead>

    <tbody> 

    <aura:iteration items="{!v.mapobject}" var="mobj" indexVar="indx">

    <tr>

    <td width="15%">

    <div class="slds-form-element slds-input-custom">

    <span>

    <lightning:select aura:id="selprod" name="{!indx+1}" value="{!mobj.selectedprod}" class="text_size" onchange="{!c.getmapmeth}">

    <option  text="--None--" label="--None--" />

    <aura:iteration items="{!v.brandlst}" var="pdesc">

    <option  text="{!pdesc}" label="{!pdesc}" />

    </aura:iteration>

    </lightning:select><br/>

    </span>

    </div>

    </td>

    <td width="20%">

    <div class="slds-form-element">

    <span>

    <lightning:select value="{!mobj.selectedproddesc}" class="text_size">

    <option text="--None--" label="--None--" />

    <aura:iteration items="{!mobj.proddesclist}" var="pdesc">

    <option text="{!pdesc}" label="{!pdesc}" />

    </aura:iteration>

    </lightning:select><br/>

    </span>

    </div>

    </td>

    </tr>

    </aura:iteration>

    </tbody>

    </table>

Helper method:

var prbwrp = component.get("v.mapobject");

        for(var n=0;n<prbwrp.length;n++)

        {

            if(index == n)

            {

                for(var k=0;k<helpervalues.length;k++)

                {

                    prbwrp[n].proddesclist.push(helpervalues[k].proddesc);

                }

                alert('Index ⌗: '+index+' = List Values: '+prbwrp[n].proddesclist);

            }

        }

Wrapper Class:

public class productdetailwrap

    {

        @AuraEnabled public String brandlist{set;get;}

        @AuraEnabled public String proddesc{set;get;}

        @AuraEnabled public list<String> proddesclist{set;get;}

        public productdetailwrap()

        {

            proddesclist=new list<String>();

        }

    }

I am seleting brand, based on selected brand i need to petch prod desc values. Values are getting js controller, but not displaying in cmp. Can anybody help me to resolve this issue.

Thanks in advance!
2 respostas
  1. 27 de ago. de 2020, 14:52
    Can you try using value attribute in <option></option>? also, does it work fine when you hardcode the values? 

    See example in this documentation
0/9000