Skip to content

Commit b13457c

Browse files
Tsvetomir-Hrntacheva
andauthoredApr 28, 2025
docs(MultiSelect): add docs for custom values (#2917)
* docs(MultiSelect): add docs for custom values * chore(MultiSelect): polish article * Update components/multiselect/custom-value.md Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> * Update components/multiselect/overview.md Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> --------- Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com>
1 parent 0a46045 commit b13457c

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
 
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Custom Values
3+
page_title: MultiSelect - Custom Values
4+
description: Learn how to use custom values and user input in the MultiSelect for Blazor.
5+
slug: multiselect-custom-values
6+
tags: telerik,blazor,multiselect,custom,value,input
7+
published: True
8+
position: 16
9+
---
10+
11+
# MultiSelect Custom Values
12+
13+
The MultiSelect component lets users type their own values that are not part of the options predefined by the developer.
14+
15+
The text entered by the user can still go into the collection that MultiSelect component is bound to through two-way binding.
16+
17+
To enable custom user input, set the `AllowCustom` parameter to `true`. When the user types a custom value, it appears as the first item in the list with the label: `Use "typed value"`. The user must select (click) the value, to actually add it the collection of values that MultiSelect is bound to. Refer to the example below to see the feature in action.
18+
19+
> When custom values are enabled, the `TextField`, `ValueField` and the `Value` must be of type `string`. Otherwise an exception will be thrown. Strings are required because the user input can take any form and may not be parsable to other types (such as numbers or GUID).
20+
21+
When custom input is allowed, the [`ValueChanged` event](slug:multiselect-events#valuechanged) fires on every keystroke, instead of when an item is selected. This happens because the MultiSelect component behaves like a text input.
22+
23+
>caption Allow custom user input in the MultiSelect component
24+
25+
````RAZOR
26+
<TelerikMultiSelect Data="@Cities"
27+
@bind-Value="@SelectedCities"
28+
TextField="@nameof(City.CityName)"
29+
ValueField="@nameof(City.CityName)"
30+
AllowCustom="true"
31+
Placeholder="Select a city for the list or type a custom one"
32+
Width="400px">
33+
</TelerikMultiSelect>
34+
35+
@code {
36+
private List<City> Cities { get; set; } = new();
37+
private List<string> SelectedCities { get; set; } = new();
38+
39+
protected override void OnInitialized()
40+
{
41+
Cities = new List<City>
42+
{
43+
new City { CityId = 1, CityName = "New York"},
44+
new City { CityId = 2, CityName = "London"},
45+
new City { CityId = 3, CityName = "Tokyo"},
46+
new City { CityId = 4, CityName = "Paris"},
47+
new City { CityId = 5, CityName = "Sydney"}
48+
};
49+
50+
base.OnInitialized();
51+
}
52+
53+
public class City
54+
{
55+
public int CityId { get; set; }
56+
public string CityName { get; set; } = string.Empty;
57+
}
58+
}
59+
````
60+
61+
## Limitations
62+
63+
* `AllowCustom` is not compatible with [adaptive rendering](slug:adaptive-rendering).
64+
65+
## See Also
66+
67+
* [MultiSelect Overview](slug:multiselect-overview)

‎components/multiselect/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ The Blazor MultiSelect provides various parameters that allow you to configure t
9999
| ----------- | ----------- | ------ |
100100
| `AdaptiveMode` | `AdaptiveMode` <br /> (`None`) | The [adaptive mode](slug:adaptive-rendering) of the component. |
101101
| `AutoClose` | `bool` <br /> (`true`) | Defines whether the dropdown list containing the items for the MultiSelect will automatically close after each user selection. |
102+
| `AllowCustom` | `bool` | Determines if the user can enter [custom values](slug:multiselect-custom-values). If enabled, the `ValueField` must be a `string`. |
102103
| `ShowClearButton` | `bool` | Whether the user will have the option to clear the selected items with a button on the input. When it is clicked, the `Value` will be updated to an empty list. |
103104
| `Data` | `IEnumerable<TItem>` | Allows you to provide the data source. Required. |
104105
| `DebounceDelay` | `int` <br/> 150 | Time in milliseconds between the last typed symbol and the internal `oninput` event firing. Applies when the user types and filters. Use it to balance between client-side performance and number of database queries. |

0 commit comments

Comments
 (0)