This is a migrated thread and some comments may be shown as answers.

MultiSelect Force Selection

1 Answer 19 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 11 Feb 2021, 02:27 PM

     Hello, 
I have created a multiselect that has default values (coming from the server) in an array that I then add to the kendoMultiSelect object as follows: 

$("#subscriptionsWindow").kendoMultiSelect({
                    dataTextField: "text",
                    dataValueField: "value",
                    dataSource: multiData,
                    filter: "contains",
                    value: defaults //defaults here is an array of default items
                });

I want to prohibit the user from deselecting these values, as they are enforced by the admin but must be shown in the drop down list.

I tried the read only option and that didn't work... 

Thanks

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 15 Feb 2021, 11:13 AM

Hello Ali,

When the readonly method is used for the MultiSelect, the user will not be able to either deselect or select items. The readonly method is suitable for scenarios where you want entirely to forbid the user to change the MutliSelect value.

In case you want to allow the user to add more items to the MultiSelect, but to forbid deselecting of certain items, I would suggest you using the deselect event. In the event handler, you could check the dataItem of the currently deselected item and prevent the default behavior if needed. 

In the Dojo example linked here, the first Multiselect is read-only. In the second MultiSelect, the items added to the initial value of the widget could not be deselected. 

Please take a look at the provided suggestion and let me know in case you have additional questions on the matter.

Regards,
Neli
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
Ali
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or