Picklist Values in Dynamic Lightning Components

Is there an out-of-the-box solution to populate record-type specific picklist values when creating a picklist dynamically (in a Lightning Component) that references an sObject field?

At this point it looks like all picklist (ui:inputSelect) values must be created as ui:inputSelectOptions and will not populate dynamically. This is problematic for record types since we can’t get record-type specific picklist values from the server-side controller.

Also, thoughts/best practices for handling dependent picklists?

Your insights are appreciated.

Answer

After switching from ui:inputSelect to lightning:select , I was able to use the standard html options.

MyComponent.cmp

<aura:attribute name="options" type="String[]" />
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<aura:attribute name="selectValue" type="String" />
<lightning:select aura:id="myselection" value="{!v.selectValue}">
<aura:iteration items="{!v.options}" item="option">
<option value="{!option}">{!option}</option>
</aura:iteration>
</lightning:select>

MyComponent.controller

doInit:function(component,event,helper){
component.set('v.options',['jan','feb','mar']);
component.find('myselection').set('v.value','feb');
}

Attribution
Source : Link , Question Author : sagacious , Answer Author : Sid

Leave a Comment