I'm trying to migrate a Html.ListBoxFor() over to a Html.Telerik().MultiSelectFor() to gain a bit of fancy UI, but the HTTP form posts are incompatible with the Model, and it seems excessive to make a new model binder to avoid it.
public class Settings
{
public int[] UserIds { get; set; }
public IEnumerable<SelectListItem> UserSelectList { get; set; }
}
When I use the Html.ListBoxFor helper, the HTTP form post includes just the value of the Select List Item (i.e. an array of UserIds), as expected.
UserIds[0] = 1
UserIds[1] = 2
@Html.ListBoxFor(model => model.UserIds, Model.UserSelectList)
When I use the Kendo MultiSelect, the HTTP form post includes two properties. Which is not expected.
UserIds[0].Text = Adrian
UserIds[0].Value = 1
...
@Kendo().MultiSelectFor(model => Model.UserIds).BindTo(Model.UserSelectList)
Does anyone know a way to get the Kendo MultiSelect to just post the id value back, or is there a ready-made Model Binder?
You just need to set the Primitive value to true which will get only the value list.
.ValuePrimitive(true)
For reference: Is Primitive Sample