Although that the ListBox is similar to the MultiSelect, at the moment it does not have such model binding, because it is also comparable with the data management widgets and for the initial release of the ListBox our developers decided to consider the model binding only if there is demand for it. With that in mind, you could create a feature request in our public portal for that feature: http://www.telerik.com/forums/listbox-bind-to-model-view
Hello Martin,
Thank you for your feedback. Our Dev Team will have it in mind if this idea is going to be implemented.
Regards,
Anton Mironov
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/.
Hello,
While the Kendo UI ListBox does not have the necessary bindings, it is possible to use it as an editor with the following approach which will bind the Locations thanks to the data_bind attribute and will act in the same way as MultiSelectFor(x=>x.Locations) including saving the new collection in the model.Location property and posting it together with the full model on update:
.Columns(columns =>
{ // grid column bound to a collection
columns.Bound(p => p.Locations).ClientTemplate("#= getTemplate(data) #");
// Custom popup editor contains the Locations Listbox
@(Html.Kendo().ListBox()
.Name("Locations")
.DataValueField("Id")
.DataTextField("Name")
.ConnectWith("Available")
.HtmlAttributes(new { data_bind = "source:Locations" })
.Selectable(ListBoxSelectable.Multiple)
)
function getTemplate(data) {
if (data.Locations.length) {
var template = "<ul>";
$.each(data.Locations, function (idx, location) {
template += "<li>" + location.Name + "</li>"
});
template += "</ul>";
return template;
}
return "";
}
I am attaching a runnable project here, just include a reference to the Kendo.Mvc.dll, build and run.
The same project is also available for ASP.NET Core here:
Kind Regards,
Alex Hajigeorgieva
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/.
I would have used it. Seems strange that it's missing.