I have a model bound via MVVM with a collection of related entities:
01.@(Html.Kendo().MultiSelectFor(m => m.AmendedRegulations)02. .DataTextField("Title")03. .DataValueField("Id")04. .Animation(false).AutoBind(false)05. .HtmlAttributes(new06. {07. @class = "form-control",08. data_bind = "value: regulation.AmendedRegulations"09. })10. .Filter(FilterType.Contains)11. .AutoClose(false)12. .DataSource("amendedRegulationsDataSource")13.)
The data structure retrieved by amendedRegulationsDataSource and AmendedRegulation have {Id : int, Title: string}.
01.let amendedRegulationsDataSource = new kendo.data.DataSource({02. serverFiltering: false,03. transport: {04. read: {05. url: "@ViewData["ApiUrl"]/regulations/regulations-for-dropdowns",06. dataType: "json",07. type: "GET",08. data: function() {09. 10. return { datasetId : viewModel.regulation.DatasetId }11. }12. }, 13. }14.});
01.$(function () {02. 03. languagesDataSource.read();04. 05. viewModel.regulationDataSource.fetch(function() {06. 07. viewModel.set("regulation", this.data()[0]);08. kendo.bind($("#edit-regulation"), viewModel);09. 10. // amendedRegulationsDataSource.read();11. });12.});
When kendo.bind executes, the data in AmendedRegulations is bound, is displayed in the multi select, however, when I click the multi select, to maybe change the selection, the selected items disappear, which causes confusion to the user.
Now, is there a setting that I need to make/activate in order to preserve the selected items in the multi select?
Thank you.