+ Start a Discussion
mukesh guptamukesh gupta 

Lightning component picklist

Hi expert,

I have multiple country picklist in lightning compont that's is iterating in Table TR
we i choose any picklist value 'UAS' and click on save button than this picklist should be disable.

but when i change of picklist then picklist disable on selection time. but i want to disable on save button.

Please suggest
<aura:iteration items="{!v.CountryDetails}" var="item" >
<tr> 
<td class="slds-cell-wrap">
                        <lightning:select name="statusFld" label="" value="{!item.Country__c}" disabled="{!item.Country__c == 'Closed Won')}">
                            <option value="--None--">--None--</option>
                            <aura:iteration items="{!v.listCountry}" var="val">
                                <option value="{!val.value}" selected="{!val.value==item.Country__c}">{!val.key}</option>
                            </aura:iteration>
                        </lightning:select>
                    </td>
</tr>
</aura:iteration>

 
Nayana KNayana K
Can you please provide full code?
Basically what you need to do is take an Boolean aura attribute which is false initially. On click of save make it true. Conditionally disable the picklist. Eg:
 
<aura:attribute name="isSaveClicked" type="Boolean" default="false">

............................
 
<aura:iteration items="{!v.CountryDetails}" var="item" >
<tr> 
<td class="slds-cell-wrap">
                        <lightning:select name="statusFld" label="" value="{!item.Country__c}" disabled="{!and(item.Country__c == 'Closed Won', v.isSaveClicked))}">
                            <option value="--None--">--None--</option>
                            <aura:iteration items="{!v.listCountry}" var="val">
                                <option value="{!val.value}" selected="{!val.value==item.Country__c}">{!val.key}</option>
                            </aura:iteration>
                        </lightning:select>
                    </td>
</tr>
</aura:iteration>


controller/helper:
 
({ 
"save" : function(cmp) {
// rest of the logic
cmp.set("v.isSaveClicked", true);
}

})

​​​​​​​