public class multiPicklistCtrl {
@AuraEnabled
public static List < String > getselectOptions(sObject objObject, string fld) {
system.debug('objObject --->' + objObject);
system.debug('fld --->' + fld);
List < String > allOpts = new list < String > ();
// Get the object type of the SObject.
Schema.sObjectType objType = objObject.getSObjectType();
// Describe the SObject using its object type.
Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
// Get a map of fields for the SObject
map < String, Schema.SObjectField > fieldMap = objDescribe.fields.getMap();
// Get the list of picklist values for this field.
list < Schema.PicklistEntry > values =
fieldMap.get(fld).getDescribe().getPickListValues();
// Add these values to the selectoption list.
for (Schema.PicklistEntry a: values) {
allOpts.add(a.getValue());
}
system.debug('allOpts ---->' + allOpts);
allOpts.sort();
return allOpts;
}
}
Thanks for your response. My concern right now is not just displaying picklist values in a lightning component, but it is displaying the picklist values in 4 different columns. Lets say I have 20 picklist values and I want them to be displayed in 4 different columns with 5 values in each column as shown in the file above.
- Use Dynamic apex to get the picklist values from the table
- Return the values as Set of String in apex controller
- Use aura:iteration in component and show earch value as check list
- While saving them save the values as comma separted to fields
http://sfdcmonkey.com/2018/02/25/fetch-multi-picklist-values-lightningduallistbox-component/http://sfdcmonkey.com/2018/02/20/multi-select-lookup-salesforce-lightning/
https://www.soliantconsulting.com/blog/create-a-custom-salesforce-lightning-multiselect-component/
Thanks for your response. My concern right now is not just displaying picklist values in a lightning component, but it is displaying the picklist values in 4 different columns. Lets say I have 20 picklist values and I want them to be displayed in 4 different columns with 5 values in each column as shown in the file above.
Thanks,
Lucky