Hi all.
I have a multiselect widget with a client side added item. Selectin this item as default selection doesn't work. This is the widget definition:
@(Html.Kendo().MultiSelect().Name(componentName: "orderTypeSelector") .DataSource(ds => ds.Read((read => read.Route(OrderTypeControllerRoute.GetReadList, new RouteValueDictionary { { "culture", UICulture.ToLower() } })))) .Events(e => { e.DataBound(handler: "orderTypeDataBound"); e.Select(handler: "orderTypeSelect"); }) .DataValueField(nameof(OrderTypeViewModel.Id)) .DataTextField(nameof(OrderTypeViewModel.Label)) .Value(new[] {new OrderTypeViewModel { Id = 0, Label = "Alle", BackgroundColor= "rgba(0, 0, 0, 1)", MasterSystemId="*" } }) .Deferred())And these are the javascript event handlers:
// order type multiselect eventsfunction orderTypeDataBound(e) { var ds = this.dataSource; if (ds.at(0).@nameof(OrderTypeViewModel.Id) !== 0) { ds.insert(0, { @nameof(OrderTypeViewModel.Id): 0, @nameof(OrderTypeViewModel.Label): "Alle" }); }}function orderTypeSelect (e) { var dataItemValue = this.dataSource.view()[e.item.index()].value; var values = this.value(); if (dataItemValue !== "Alle" && contains(dataItemValue, values)) { return; } if (dataItemValue === "Alle") { values = []; } else if (values.indexOf("Alle") !== -1) { values = $.grep(values, function(value) { return value !== "Alle"; }); } values.push(dataItemValue); this.value(values); this.trigger("change"); //notify others for the updated values e.preventDefault();}What am I missing here?
Kind regards
Bernd
