getting picklist values dynamically by w3web.net

How to fetch picklist values from apex controller in lightning component

Hey guys, In this post we are going to learn about how to retrieve Picklist values from Apex controller in Lightning Component.

Files we used in this post example:-

statusApp.app Lightning Application It is used for call the component to preview on browser.
statusCmp.cmp Lightning Component It is used for create a picklist select option field.
statusCmpController.js JavaScript Controller File It is used for communicate to server side apex method and fetch the picklist value from init fuction.
statusCmpHelper.js JavaScript Helper File Helper function call in to javascript init function.
pickListController.apxc Apex Class Controller It is used for retrieve picklist values from database.

Custom Object:- Course__c

Custom Object Picklist Fields:-

Status__c

Picklist Value:-

Active,

Inactive

 

Custom Object and their fields

We retrieve picklist values from custom field and display on the dropdown.

 

Go through the below points step-by-step

Step 1:- Create Lightning Application : statusApp.app

From Developer Console >> File >> New >> Lightning Application

statusApp.app [Component Application File]

Step 2:- Create Lightning Component : statusCmp.cmp

From Developer Console >> File >> New >> Lightning Component

statusCmp.cmp [Lightning Component]

Step 3:- Create Lightning Component : statusCmpController.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

statusCmpController.js [JavaScript Controller]

Step 4:- Create Lightning Component : statusCmpHelper.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Helper

statusCmpHelper.js [JavaScript Helper]

Step 5:- Create Lightning Application : pickListController.apxc

From Developer Console >> File >> New >> Apex Class

pickListController.apxc [Apex Class Controller]

Other related post that would you like to learn…

Step 6:- Final Output

fetching picklist values dynamically in lightning by w3web.net

Leave a Comment