Multiselect readonly

1 Answer 26 Views
MultiSelect
Raymond
Top achievements
Rank 1
Raymond asked on 16 Feb 2022, 03:03 PM

How can I make a Multiselect readonly?

I want to show a list of "chips" and this is very close to what I want:

<TelerikMultiSelect Data="@Values" Enabled="true" @bind-Value="@Values" ClearButton="true" AutoClose="false" MinLength="100000" />

But I don't want the user to type anything. I can not set it to disabled because I want to be able to close the chips, so what I want is a readonly possibility. Is this possible to do?

1 Answer, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 17 Feb 2022, 07:40 PM

Hello Raymond,

If the component were read-only, then you should not be able to remove selected items.

What you can consider is using the ValueChanged event to determine what the user did - whether they tried to add or remove items, so you can update the view-model only when needed.

What I would suggest you consider instead, however, is building a custom component for this, so that you don't have the dropdown either - a basic @foreach over the models can let you render the "chips" and a button with a lambda expression can remove them by passing the current item to the handler that will update the view-model.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MultiSelect
Asked by
Raymond
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or