Skip to main content
I am getting list if string from apex and I want display those strings into one selected picklist and finally user can select one string in that picklist.

 

Apex Returns List<string>  s = [{"Banglore","Chennai","Noida"}];

At the end user able to select any one of city in selected picklist
2 个回答
  1. 2020年1月28日 12:21

    Try like this.Kindly Modify it according to your apex controller method

    <aura:component controller= "picklistvaluesController"

    implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"

    access="global" >

    <aura:attribute name="picklistvalues" type="string[]" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <lightning:select aura:id="PicklistId" label="Enter Last Class Percentage" name="percent" >

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

    <aura:iteration items="{!v.picklistvalues}" var="pickval">

    <option value="{!pickval}" text="{!pickval}" />

    </aura:iteration>

    </lightning:select>

    </aura:component>

    js controller

    ({

    doInit : function(component, event, helper) {

    var action = component.get("c.getPicklistvalues");

    action.setCallback(this, function(response) {

    var Values = response.getReturnValue();

    component.set("v.picklistvalues", values);

    });

    $A.enqueueAction(action);

    }

    })

    Please refer below link which might help you in this

    https://developer.salesforce.com/forums/?id=9060G0000005pEeQAI 

    Hope this helps you

    Let me know if this helps you by marking it as solved so that it may help others in future.

    Thanks and Regards