Class SfMultiSelect<TValue, TItem>
The MultiSelect component contains a list of predefined values from which a multiple value can be chosen.
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 | Specifies the value type. |
TItem | Specifies the type of SfMultiSelect. |
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, OnResizing, and OnResizeStop events to monitor or restrict resizing behavior.
Examples
@code {
private void HandleResizeStart(object args) {
Console.WriteLine("Resize started.");
}
private void HandleResizing(object args) {
Console.WriteLine("Resizing...");
}
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()
Allows you to clear the selected values from the MultiSelect component.
Declaration
public Task ClearAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
DisableItem(Object)
Method to disable a specific item in the popup.
Declaration
public Task DisableItem(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The value or index of the item to be disabled. |
Returns
Type |
---|
System.Threading.Tasks.Task |
Remarks
This method disables a specific item in the popup based on the provided item
.
If the item is of type TValue
, it represents the value associated with the item.
If the item is of type System.String, it represents the value of the item in the popup.
If the item is of type System.Int32, it represents the index of the item in the popup.
FilterAsync(IEnumerable<TItem>, Query, FieldSettingsModel)
To filter the data from given data source by using query.
Declaration
public Task FilterAsync(IEnumerable<TItem> dataSource, Query query = null, FieldSettingsModel fields = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | Specifies the data source. |
Query | query | Specifies the query. |
FieldSettingsModel | fields | Specifies the fields. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
FilteringActionAsync(IEnumerable<TItem>, Query, FieldSettingsModel)
Task which specifies the filtering action.
Declaration
protected Task FilteringActionAsync(IEnumerable<TItem> dataSource, Query query, FieldSettingsModel fields)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | Specifies the data source. |
Query | query | Specifies the query. |
FieldSettingsModel | fields | Specifies the fields. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
FocusAsync()
Sets the focus to the MultiSelect component for interaction.
Declaration
public Task FocusAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
FocusOutAsync()
Remove the focus from the MultiSelect component, if the component is in focus state.
Declaration
public Task FocusOutAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
GetDataByValueAsync(TValue)
Gets the array of data Object that matches the given array of values.
Declaration
public Task<List<TItem>> GetDataByValueAsync(TValue dataValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | dataValue | Specifies the value(s). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<TItem>> | Task. |
GetForQuery(List<Object>, Boolean)
Declaration
protected Query GetForQuery(List<object> values, bool isCheckBox = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.Object> | values | |
System.Boolean | isCheckBox |
Returns
Type |
---|
Query |
GetItemsAsync()
Gets all the list items bound on this component.
Declaration
public Task<IEnumerable<TItem>> GetItemsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TItem>> | Task. |
HidePopupAsync()
Hides the popup if it is in an open state.
Declaration
public Task HidePopupAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
RefreshDataAsync()
Refreshes the popup list items. The method is useful if the popup list item changed externally.
Declaration
public Task RefreshDataAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | System.Threading.Tasks.Task. |
SelectAllAsync(Boolean)
Based on the state parameter, entire list item will be selected/deselected.
parameter
- TrueSelects entire list items.
- FalseUn Selects entire list items.
Declaration
public Task SelectAllAsync(bool state)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | state | Specifies the state. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
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 the popup that displays the list of items.
Declaration
public Task ShowPopupAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
UpdateValueAsync()
Task which updates the value.
Declaration
protected Task UpdateValueAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |