-
Notifications
You must be signed in to change notification settings - Fork 79
docs(MultiSelect): add docs for custom values #2917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
647997b
docs(MultiSelect): add docs for custom values
Tsvetomir-Hr e1a14e2
chore(MultiSelect): polish article
Tsvetomir-Hr db55eef
Update components/multiselect/custom-value.md
Tsvetomir-Hr bc76e05
Update components/multiselect/overview.md
Tsvetomir-Hr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Custom Value | ||
page_title: MultiSelect - Custom Value | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: Custom values and user input in the MultiColumnComboBox for Blazor. | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
slug: multiselect-custom-value | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tags: telerik,blazor,multiselect,custom,value,input | ||
published: True | ||
position: 16 | ||
--- | ||
|
||
# MultiSelect Custom Values | ||
|
||
The MultiSelect component allows the user to type in their own value that is not a part of the predefined set of options that the developer provided. | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The text entered by the user can still go into the field the combo box is bound to through two-way binding. | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To enable custom user input, set the `AllowCustom` parameter to `true`. When the user types a custom value, it will appear as the first item in the list with the label: `Use"typed value"`. Refer to the example below to see it in action. | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
> When MultiSelect is bound to a model, 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). | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
When custom input is allowed, the [ValueChanged event](slug:multiselect-events#valuechanged) fires on every keystroke, and not when an item is selected, because the MultiSelect component acts as a text input. | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
>caption Allow custom user input in the MultiSelect component | ||
|
||
````RAZOR | ||
<TelerikMultiSelect Data="@Cities" | ||
@bind-Value="@SelectedCities" | ||
TextField="@nameof(City.CityName)" ValueField="@nameof(City.CityName)" | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AllowCustom="true" | ||
Placeholder="Select city for the list or type a custom one" | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Width="400px"> | ||
</TelerikMultiSelect> | ||
|
||
@code { | ||
private List<City> Cities { get; set; } = new(); | ||
private List<string> SelectedCities { get; set; } = new(); | ||
|
||
protected override void OnInitialized() | ||
{ | ||
Cities = new List<City> | ||
{ | ||
new City { CityId = 1, CityName = "New York"}, | ||
new City { CityId = 2, CityName = "London"}, | ||
new City { CityId = 3, CityName = "Tokyo"}, | ||
new City { CityId = 4, CityName = "Paris"}, | ||
new City { CityId = 5, CityName = "Sydney"} | ||
}; | ||
|
||
base.OnInitialized(); | ||
} | ||
|
||
public class City | ||
{ | ||
public int CityId { get; set; } | ||
public string CityName { get; set; } = string.Empty; | ||
} | ||
} | ||
```` | ||
|
||
## Limitations | ||
|
||
* `AllowCustom` is not compatible with [Adaptive rendering](slug:adaptive-rendering). | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## See Also | ||
|
||
* [MultiSelect Overview](slug:multiselect-overview) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.