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"
]
Label
Text string
Sets the label of the widget.
Position string
Sets the placement of the Label in the widget.
Options:
- Left: The label is placed on the left of the widget.
- Top: The label gets placed at the top of the widget.
- Auto: The label position is determined based on the height of the widget itself.
Alignment string
Sets the label alignment of the widget when the position selected is Left.
Width (in columns) number
Sets the width of the label in the widget when the Left position is selected.
Search and filters
Allow searching boolean
Enables searching for options within the dropdown list. When this option is enabled, a search input field is displayed in the widget. Additionally, you can control it through JavaScript by clicking on the JS next to the property.
Server side filtering boolean
Enables server-side filtering via a query request. Use this property when the MultiSelect widget's option data is being bound to a query.
onFilterUpdate
This event allows you to configure one or multiple actions (Framework functions, queries, or JS functions) to be executed when you update the filter text. You can also write custom JavaScript logic for this event by clicking on the JS next to the property.
Validations
Required boolean
Enabling this property for a MultiSelect widget makes it a mandatory field, meaning that the user must select a value from the dropdown. When the MultiSelect widget is placed within a Form widget and the Required property is enabled, the Form's submit button remains inactive until a value is selected in the MultiSelect widget.
General
Tooltip string
Sets a tooltip for the widget. You can add hints or extra information about the required input from the user
Placeholder string
Sets the placeholder text for the MultiSelect widget.
Visible boolean
Controls the visibility of the widget. If you turn off this property, the widget is not visible in View mode. Additionally, you can use JavaScript by clicking on JS next to the Visible property to control the widget's visibility conditionally.
For example, if you want to make the widget visible only when the user checks an item in a Checkbox widget, you can use the following JavaScript expression in the visible property of the MultiSelect widget:
{{Checkbox1.isChecked}}
Disabled boolean
Prevents users from selecting the widget. Even though the widget remains visible, user input is not permitted. Additionally, you can use JavaScript by clicking on JS next to the Disabled
property to control the widget's disabled state conditionally.
For example, if you want to allow only a specific user to interact with the Multi+-select widget, you can use the following JavaScript expression:
{{appsmith.user.email=="john@appsmith.com"?false:true}}
Animate Loading boolean
Controls whether the widget is displayed with a loading animation. When enabled, the widget shows a skeletal animation during the loading process. Additionally, you can control it through JavaScript by clicking on the JS next to the property.