MultiSelect
This page explains how to use a MultiSelect widget to allow users to select multiple options from a given list.
Content properties
These properties are customizable options present in the property pane of the widget, allowing users to modify the widget according to their preferences.
Data
Source Data array<object>
Specify data as an array of objects to display options in the widget. For example:
[
{
name: "Blue",
code: "BLUE"
},
{
name: "Green",
code: "GREEN"
},
{
name: "Red",
code: "RED"
},
];
You can dynamically generate options by fetching data from queries or JS functions and binding the response to the Source Data property. For example, if you have a query named fetchData
, you can bind its response using:
{{fetchData.data}}
If the retrieved data is not in the desired format, you can use JavaScript to transform the data by adding it to the Source Data property, like:
{{fetchData.data.map( p => ({label: p.country, value: p.country}))}}
If you are generating options for MutliSelect widget using JS code as shown above, you must define both the Label and Value properties.
Label string
Defines the key from the Source Data property that specifies the labels for each option in the MultiSelect widget. To define Label using code, click the JS button next to the property.
Example: If you prefer the label to be displayed in lowercase, you can achieve this using the following code snippet:
{{ item.name.toLowerCase() }}
item.name
represents the Source Data's property containing the label, and the toLowerCase()
function is applied to convert the label to lowercase.
Value string
Defines the key from the Source Data property that specifies the values for each option in the MultiSelect widget. Value defined for each option must be unique. To define Value using code, click the JS button next to the property.
Default selected value string
Sets the initial options that are automatically chosen when the widget is loaded. It serves as the default selection unless the user manually selects another option from the list. Multiple values can be provided in a CSV format or an array of strings for a MultiSelect dropdown. For example, if you want the default option to be Blue
and Red
, set the Default Selected Value property to:
[
"GREEN",
"RED"
]