Class SfMultiSelect<TValue, TItem>
Syncfusion Blazor MultiSelect dropdown control that allows selection of one or more items from a list, with advanced search and filtering capabilities.
Implements
Inherited Members
Namespace: Syncfusion.Blazor.DropDowns
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfMultiSelect<TValue, TItem> : SfDropDownBase<TItem>, IDropDowns, IVirtualList<TItem>
Type Parameters
Name | Description |
---|---|
TValue | The value type for the selected item(s). Supports primitives or collection. |
TItem | The type of each list item in the data source. Typically a DTO or primitive. |
Remarks
Supports data-driven item rendering, customizable field mapping, filtering, virtualization, checkboxes, custom value entry, and keyboard navigation.
Examples
<SfMultiSelect TValue="string" TItem="Product" DataSource="@Products" AllowFiltering="true">
<MultiSelectFieldSettings Text="Name" Value="Id" />
</SfMultiSelect>
@code {
List<Product> Products = ...;
}
<SfMultiSelect TValue="string[]" TItem="Country" DataSource="@CountryList">
<MultiSelectFieldSettings Text="Name" Value="IsoCode" />
</SfMultiSelect>
@inject SfMultiSelect<string[], Country> MyMultiSelectRef;
...
await MyMultiSelectRef.ClearAsync(); // Clear selection from code
await MyMultiSelectRef.ShowPopupAsync(); // Open the item dropdown programmatically
Constructors
SfMultiSelect()
Declaration
public SfMultiSelect()
Properties
AllowCustomValue
Gets or sets a value indicating whether the MultiSelect Dropdown component allows entering custom values.
Declaration
public bool AllowCustomValue { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
AllowFiltering
Gets or sets a value indicating whether filtering is allowed in the MultiSelect Dropdown component.
Declaration
public bool AllowFiltering { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
If the searching character does not match, the NoRecordsTemplate
property value will be shown.
AllowResize
Gets or sets a value indicating whether the resizing option is enabled for the popup.
Declaration
public bool AllowResize { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When AllowResize
is set to true
, the popup includes a resizable handle at the bottom right corner, enabling users to adjust its size.
This resizing functionality can be further controlled using the OnResizeStart and OnResizeStop events to monitor or restrict resizing behavior.
Examples
@code {
private void HandleResizeStart(object args) {
Console.WriteLine("Resize started.");
}
private void HandleResizeStop(object args) {
Console.WriteLine("Resize stopped.");
}
}
CssClass
Gets or sets a CSS class string to customize the appearance of the SfMultiSelect<TValue, TItem> component.
Declaration
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts a CSS class string separated by space to customize the appearance. The default value is |
DebounceDelay
Gets or sets the debounce delay in milliseconds for filtering the items in the SfMultiSelect<TValue, TItem> component. The debounce delay represents the time delay between the last keystroke and the filtering operation. This delay helps reduce the frequency of data filtering while typing. The default value is 300 milliseconds.
The DebounceDelay property only takes effect when the AllowFiltering property is set to true
.
Declaration
public int DebounceDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer representing the debounce delay in milliseconds. The default value is 300. |
Remarks
The DebounceDelay property helps optimize performance by delaying the filtering operation
until the user has stopped typing for the specified delay duration.
To work with the default filtering scenario, the user needs to set the DebounceDelay
value to zero.
Examples
The following example demonstrates how to set the DebounceDelay property to 500 milliseconds.
DelimiterChar
Gets or sets the delimiter character used to separate selected items in the MultiSelect Dropdown component.
Declaration
public string DelimiterChar { get; set; }
Property Value
Type | Description |
---|---|
System.String | The delimiter character used for item separation. The default value is ",". |
EnableChangeOnBlur
Gets or sets a value indicating whether the value change should occur on blur for the MultiSelect Dropdown component.
Declaration
public bool EnableChangeOnBlur { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableCloseOnSelect
Gets or sets a value indicating whether the dropdown should close automatically after selecting an item in the MultiSelect Dropdown component.
Declaration
public bool EnableCloseOnSelect { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Enabled
Gets or sets a value indicating whether the MultiSelect Dropdown component is enabled.
Declaration
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableGroupCheckBox
Gets or sets a value indicating whether the group checkbox is enabled in the MultiSelect Dropdown component.
Declaration
public bool EnableGroupCheckBox { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This property allows you to render checkbox for group headers and to select all the grouped items at once.
EnablePersistence
Gets or sets a value indicating whether the component's state should be persisted between page reloads.
Declaration
public bool EnablePersistence { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableRtl
Gets or sets whether the right-to-left direction is enabled for the MultiSelect Dropdown component.
Declaration
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableSelectionOrder
Gets or sets a value indicating whether the selection order is enabled in the MultiSelect Dropdown component.
Declaration
public bool EnableSelectionOrder { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableVirtualization
Gets or sets a value indicating whether virtualization is enabled for the MultiSelect Dropdown component.
Declaration
public bool EnableVirtualization { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
The Virtual Scrolling feature is used to display a large amount of data that you require without buffering an entire load of huge database records in the DropDowns, that is, when scrolling, the datamanager request is sent to fetch some amount of data from the server dynamically.
FilterBarPlaceholder
Gets or sets the placeholder text displayed in the filter bar of the MultiSelect Dropdown component.
Declaration
public string FilterBarPlaceholder { get; set; }
Property Value
Type | Description |
---|---|
System.String | The placeholder text for the filter bar. |
FloatLabelType
Gets or sets the type of floating label to be displayed in the MultiSelect Dropdown component.
Declaration
public FloatLabelType FloatLabelType { get; set; }
Property Value
Type | Description |
---|---|
FloatLabelType | Possible values are:
|
FooterTemplate
Gets or sets the template to be rendered as the footer of the dropdown popup in the MultiSelect component.
Declaration
public RenderFragment FooterTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment | The template content. The default value in |
HeaderTemplate
Gets or sets the template to be rendered as the header of the dropdown popup in the MultiSelect component.
Declaration
public RenderFragment HeaderTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment | The template content. The default value in |
HideSelectedItem
Gets or sets a value indicating whether the selected item should be hidden in the popup list of the MultiSelect Dropdown component.
Declaration
public bool HideSelectedItem { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HtmlAttributes
Gets or sets the HTML attributes to be applied to the MultiSelect Dropdown component.
Declaration
public Dictionary<string, object> HtmlAttributes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | The HTML attributes as a dictionary. |
Remarks
If you configured both the property and equivalent input attribute, then the component considers the property value.
ID
Gets or sets the identifier of the MultiSelect Dropdown component.
Declaration
public string ID { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
InputAttributes
You can add the additional input attributes such as disabled, value, and more to the root element.
If you configured both the property and equivalent input attribute, then the component considers the property value.
Declaration
public Dictionary<string, object> InputAttributes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | A dictionary of additional input attributes for the root element of the component. |
ItemsCount
Gets or sets the number of items to be fetched in the popup based on the ItemsCount when EnableVirtualization is enabled.
Declaration
public int ItemsCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer value representing the number of items to be fetched. The default value is |
MaximumSelectionLength
Gets or sets the maximum number of items that can be selected in the MultiSelect Dropdown component.
Declaration
public int MaximumSelectionLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer value representing the maximum number of items that can be selected in the list. The default value is |
Mode
Gets or sets the visual mode of the MultiSelect Dropdown component.
Declaration
public VisualMode Mode { get; set; }
Property Value
Type | Description |
---|---|
VisualMode | The visual mode of the MultiSelect Dropdown. The default value is Default. |
OpenOnClick
Gets or sets a value indicating whether the dropdown should open when the MultiSelect component is clicked.
Declaration
public bool OpenOnClick { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Placeholder
Gets or sets the placeholder text to be displayed in the MultiSelect input when no items are selected.
Declaration
public string Placeholder { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
PopupDisplayMode
Gets or sets the display mode of the dropdown popup on mobile devices.
Declaration
public PopupDisplayMode PopupDisplayMode { get; set; }
Property Value
Type | Description |
---|---|
PopupDisplayMode | The default value is FullScreen. |
Remarks
The PopupDisplayMode enum has two possible values:
- FullScreen: The popup opens in fullscreen mode on mobile devices when filtering is enabled. This is applicable for both SfDropDownList<TValue, TItem> and SfMultiSelect<TValue, TItem> components in checkbox mode with filtering enabled.
- Inline: The popup opens similarly on both mobile and desktop devices, above the input field without fullscreen mode.
Examples
The following example demonstrates how to use the PopupDisplayMode property:
MultiSelect with PopupDisplayMode set to FullScreen
<SfMultiSelect TValue="List<string>" DataSource="@Data" PopupDisplayMode="PopupDisplayMode.FullScreen" Mode="CheckBox" AllowFiltering="true">
<MultiSelectFieldSettings Text="Text" Value="Id"></MultiSelectFieldSettings>
</SfMultiSelect>
@code {
public List<MultiSelectData> Data { get; set; } = new List<MultiSelectData>
{
new MultiSelectData { Id = "1", Text = "Option 1" },
new MultiSelectData { Id = "2", Text = "Option 2" },
new MultiSelectData { Id = "3", Text = "Option 3" }
};
public class MultiSelectData
{
public string Id { get; set; }
public string Text { get; set; }
}
}
PopupHeight
Gets or sets the height of the dropdown popup in the MultiSelect component.
Declaration
public string PopupHeight { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. The default value is |
PopupWidth
Gets or sets the width of the dropdown popup in the MultiSelect component.
Declaration
public string PopupWidth { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. The default value is |
Readonly
Gets or sets a value indicating whether the MultiSelect component is in read-only mode.
Declaration
public bool Readonly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
SelectAllText
Gets or sets the text to be displayed for the "Select All" option in the MultiSelect component.
Declaration
public string SelectAllText { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
ShowClearButton
Gets or sets a value indicating whether the MultiSelect Dropdown should display a clear button to clear the selected values.
Declaration
public bool ShowClearButton { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ShowDropDownIcon
Gets or sets a value indicating whether the dropdown icon should be shown in the MultiSelect component.
Declaration
public bool ShowDropDownIcon { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ShowSelectAll
Gets or sets a value indicating whether the Select All
option should be shown in the MultiSelect component for the CheckBox mode.
Declaration
public bool ShowSelectAll { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
TabIndex
Gets or sets the tab index of the MultiSelect component.
Declaration
public int TabIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The tab index of the MultiSelect component. The default value is 0. |
Text
Gets or sets the selected list item which maps the data Text
field in the component.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
UnSelectAllText
Gets or sets the text to be displayed for the Unselect All
option in the MultiSelect component for the CheckBox mode.
Declaration
public string UnSelectAllText { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
Value
Gets the value of the selected item in the MultiSelect Dropdown component. This will be used with two-way binding.
Declaration
public TValue Value { get; set; }
Property Value
Type | Description |
---|---|
TValue | The current value of the multi select component. |
ValueChanged
Gets or sets a callback that trigger when the value changes.
Declaration
public EventCallback<TValue> ValueChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<TValue> | An event callback function. |
ValueExpression
Specifies the expression for defining the value of the bound.
Declaration
public Expression<Func<TValue>> ValueExpression { get; set; }
Property Value
Type |
---|
System.Linq.Expressions.Expression<System.Func<TValue>> |
ValueTemplate
Gets or sets the customised design content and assigns it to the selected list item in the input element of the component.
Declaration
public RenderFragment<TItem> ValueTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment<TItem> | The template content. The default value in |
Width
Gets or sets the width of the MultiSelect component.
Declaration
public string Width { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. The default value is |
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
ClearAsync()
Clears all selected values in the MultiSelect component, restoring it to its default state.
Declaration
public Task ClearAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous clear operation. |
Remarks
This method will remove all currently selected items from the MultiSelect, returning it to no-selection. Use this to programmatically reset selections (for example, in a form reset workflow).
Examples
await multiSelectRef.ClearAsync(); // Clears all selections
DisableItem(Object)
Disables a specific item in the MultiSelect list, based on value or item index.
Declaration
public Task DisableItem(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The unique item value, corresponding |
Returns
Type |
---|
System.Threading.Tasks.Task |
Remarks
Use this method to programmatically disable a single item in the popup. If a string or TValue
is provided, it matches by value; if an System.Int32, it matches by index in the item list.
Examples
await multiSelectRef.DisableItem("US"); // Disable the item with value "US"
await multiSelectRef.DisableItem(2); // Disable the item at index 2
FilterAsync(IEnumerable<TItem>, Query, FieldSettingsModel)
Filters the supplied dataSource
using the specified query
and field mapping.
Declaration
public Task FilterAsync(IEnumerable<TItem> dataSource, Query query = null, FieldSettingsModel fields = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | The enumerable data source to apply the custom filter logic on. |
Query | query | A Query instance describing custom filtering, sorting, or paging rules. May be |
FieldSettingsModel | fields | Optional field mapping configuration for data binding and filter operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous filtering operation. |
Remarks
This method can be used to replace the displayed items dynamically at runtime by supplying a new dataSource
and filter rules. Filtering can be combined with virtualization.
Examples
await multiSelectRef.FilterAsync(myData, new Query().Where("Country", "==", "USA")); // Shows only filtered items
FilteringActionAsync(IEnumerable<TItem>, Query, FieldSettingsModel)
Performs filtering on the data source based on current input/query and updates the visible list in the dropdown popup.
Declaration
protected Task FilteringActionAsync(IEnumerable<TItem> dataSource, Query query, FieldSettingsModel fields)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | The underlying list of items to filter. |
Query | query | The query/filter expression; may be |
FieldSettingsModel | fields | Field mapping information for the MultiSelect component. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the data filtering and UI update operation. |
FocusAsync()
Sets focus to the SfMultiSelect<TValue, TItem> component, enabling immediate user interaction.
Declaration
public Task FocusAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Remarks
Use this method to programmatically move keyboard focus to the MultiSelect input. This is useful when needing to set focus due to user action, form workflow, or UI navigation outside the standard tab order.
Examples
await multiSelectRef.FocusAsync(); // Sets input focus programmatically
FocusOutAsync()
Removes focus from the SfMultiSelect<TValue, TItem> component if it is currently focused.
Declaration
public Task FocusOutAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Remarks
Call this method to programmatically remove keyboard focus from the MultiSelect control, such as after form completion or on specific workflow steps.
Examples
await multiSelectRef.FocusOutAsync(); // Removes input focus programmatically
GetDataByValueAsync(TValue)
Returns the collection of TItem
data objects matching the provided selection values.
Declaration
public Task<List<TItem>> GetDataByValueAsync(TValue dataValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | dataValue | The one or more selection values (of type |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<TItem>> | A |
Remarks
For each value in dataValue
, this method will search the MultiSelect list and return the corresponding data object(s) if present. Supports array, collection, and primitive input cases.
Examples
var selectedItems = await multiSelectRef.GetDataByValueAsync(new string[] { "US", "UK" }); // Get all selected item objects
GetForQuery(List<Object>, Boolean)
Creates a query to filter (or exclude) a set of items with certain values, used with virtualization and select-all/checkbox logic.
Declaration
protected Query GetForQuery(List<object> values, bool isCheckBox = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.Object> | values | A list of item values to be included in (or excluded from) the results set. |
System.Boolean | isCheckBox | Indicates if the operation is for checkbox (select-all) logic. |
Returns
Type | Description |
---|---|
Query | A Query containing complex filter logic for the specified values and mode. |
GetItemsAsync()
Retrieves all TItem
data items currently bound and available in the MultiSelect control's list.
Declaration
public Task<IEnumerable<TItem>> GetItemsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TItem>> | A |
Remarks
Call this method to enumerate all items currently in the MultiSelect’s internal data list. This can be useful for inspection, debugging, or for building custom logic based on all available items.
Examples
IEnumerable<Country> items = await multiSelectRef.GetItemsAsync(); // Fetches all data-bound items
HidePopupAsync()
Closes the MultiSelect dropdown popup if it is currently open.
Declaration
public Task HidePopupAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous close operation. |
Remarks
Call this method to programmatically close the MultiSelect's dropdown popup. Useful for custom UI workflows or when a user/caller needs to close the popup via external actions or programmatic logic.
Examples
await multiSelectRef.HidePopupAsync(); // Closes dropdown popup
RefreshDataAsync()
Reloads and refreshes the list of items displayed in the MultiSelect dropdown popup with the current data source.
Declaration
public Task RefreshDataAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous refresh operation. |
Remarks
Use this method when the DataSource
is changed or if you modify the items collection externally and need the dropdown to reflect these updates. The method will re-render the list and reapply the selected values.
Examples
await multiSelectRef.RefreshDataAsync(); // Refreshes MultiSelect display with latest data
SelectAllAsync(Boolean)
Selects or deselects all items in the MultiSelect dropdown, depending on the specified state
value.
Declaration
public Task SelectAllAsync(bool state)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | state | If |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous select/deselect operation. |
Remarks
Call this method to programmatically select or deselect all available items in the MultiSelect dropdown. This is especially useful in scenarios with checkbox mode or when implementing custom select/clear all UI.
Examples
// Select all items
await multiSelectRef.SelectAllAsync(true);
// Deselect all items
await multiSelectRef.SelectAllAsync(false);
SetCurrentViewDataAsync(Int32, Int32)
Declaration
protected override Task SetCurrentViewDataAsync(int virtualItemStartIndex, int virtualItemEndIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | virtualItemStartIndex | |
System.Int32 | virtualItemEndIndex |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
ShowPopupAsync()
Opens and displays the MultiSelect dropdown popup, allowing selection from the available items programmatically.
Declaration
public Task ShowPopupAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous open operation. |
Remarks
This method programmatically triggers the dropdown popup, bypassing the need for user clicking the input. Use for advanced UI scenarios like opening the dropdown based on keyboard command, API call, or workflow trigger.
Examples
await multiSelectRef.ShowPopupAsync(); // Opens dropdown popup from code
StartResizingHandler(Object)
Starts the popup resizing operation for the MultiSelect dropdown (advanced scenarios; called via JS interop or custom UI logic).
Declaration
public Task StartResizingHandler(object eventArguments = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | eventArguments | Optional event argument payload for the resize start event. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task representing the resize start operation. |
StopResizingHandler(Object, Double)
Completes the popup resizing operation for the MultiSelect dropdown (advanced scenarios; called via JS interop or resize stop actions).
Declaration
public Task StopResizingHandler(object eventArguments = null, double resizeHeight = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Object | eventArguments | Optional event argument payload for the resize stop event. |
System.Double | resizeHeight | The new height value (in pixels) for the dropdown popup after resizing. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task representing the resize stop operation. |
UpdateValueAsync()
Task which updates the value.
Declaration
protected Task UpdateValueAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |