Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

DynamicPickList Class

An abstract class, used to display the values of a picklist in a Lightning component on a Lightning page.

Namespace

VisualEditor

Usage

To use this class as the datasource of a picklist in a Lightning component, it must be extended by a custom Apex class and then that class must be called in the component’s design file.

Example

Here’s an example of a custom Apex class extending the VisualEditor.DynamicPickList class.
1global class MyCustomPickList extends VisualEditor.DynamicPickList{
2    
3    global override VisualEditor.DataRow getDefaultValue(){
4        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED');
5        return defaultValue;
6    }
7    global override VisualEditor.DynamicPickListRows getValues() {
8        VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED');
9        VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW');
10        VisualEditor.DynamicPickListRows  myValues = new VisualEditor.DynamicPickListRows();
11        myValues.addRow(value1);
12        myValues.addRow(value2);
13        return myValues;
14    }
15}
Here’s an example of how the custom Apex class gets called in a design file so that the picklist appears in the Lightning component.
1<design:component>
2        <design:attribute name="property1" datasource="apex://MyCustomPickList"/>
3</design:component>

DynamicPickList Methods

The following are methods for DynamicPickList.

clone()

Makes a duplicate copy of the VisualEditor.DynamicPicklist object.

Signature

public Object clone()

Return Value

Type: Object

getDefaultValue()

Returns the picklist item that is set as the default value for the picklist.

Signature

public VisualEditor.DataRow getDefaultValue()

Return Value

Type: VisualEditor.DataRow

getLabel(attributeValue)

Returns the user-facing label for a specified picklist value.

Signature

public String getLabel(Object attributeValue)

Parameters

  • attributeValue: Type: Object The value of the picklist item.

Return Value

Type: String

getValues()

Returns the list of picklist item values.

Signature

public VisualEditor.DynamicPickListRows getValues()

isValid(attributeValue)

Returns the valid state of the picklist item’s value. A picklist value is considered valid if it’s a part of any VisualEditor.DataRow in the VisualEditor.DynamicPickListRows returned by getValues().

Signature

public Boolean isValid(Object attributeValue)

Parameters

  • attributeValue: Type: Object The value of the picklist item.

Return Value

Type: Boolean