You need to sign in to do that
Don't have an account?
shalini sharma 24
How to fetch List custom setting record from Lightning component
I want to create a picklist in lightning (<lightning:select>) and the value for the options should be fetched from List custom Setting. How can we do this?
Thanks
Thanks
Hi Shalini,
Fetch custom setting values in Apex controller and pass on to Lightning Component using JS Controller.
Thanks,
Gaurav
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="cstmSettindData">
<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
<aura:attribute name="optVal" type="List"/>
<lightning:select name="select" label="Select a value">
<option value="">-- None --</option>
<aura:iteration items="{!v.optVal}" var="op">
<option value="{!op.stage__c}" text="{!op.stage__c}"></option>
</aura:iteration>
</lightning:select>
</aura:component>
----------------------------------------------------------------------------------
({
myAction : function(component, event, helper) {
//get state when country populated- start
var optionValue = component.get("c.getListSettings");
optionValue.setCallback(this, function(a) {
component.set("v.optVal",a.getReturnValue());
});
$A.enqueueAction(optionValue);
// end
}
})
---------------------------------------------------------------------------------------
public class cstmSettindData {
@AuraEnabled
public static List<DropDown__c> getListSettings(){
List<DropDown__c> dList = new List<DropDown__c>();
dList = DropDown__c.getall().values();
return dList;
}
}
Still I cannot see the options in the picklist. Attached is the screenshot.
Any idea how was this issue fixed,i am facing the same
It works fine. However, if I use my helper function to get the data for the list from an apex list, I get the same result as shalini sharma 24. Has anybody found a solution?