I'm using the Kendo Multiselect widget, with server binding (i.e. not ajax), and MVC. It's not posting selected items to the controller. How do I do this? I've tried a few different ways, based on what I've read in your documentation, but none of them work, so rather than me continue guessing, how about if someone tells me how to do it :-)
Here's an excerpt from the View Model:
public class ViewReportDetail
{
public List<CaType> CaTypes { get; set; }
public List<CaType> AllCaTypes { get; set; }
public int[] SelectedCaTypes { get; set; }
}
Here's the multiselect widget in the view (strongly type as ViewReportDetail):
@using (Html.BeginForm("Save", "Report", FormMethod.Post))
{
@(Html.Kendo().MultiSelect()
.Name("CaTypes")
.DataTextField("Description")
.DataValueField("Id")
.BindTo(Model.AllCaTypes)
.Value(Model.SelectedCaTypes)
)
}
Here's the controller for the save (not much to see here):
public ActionResult Save(ViewReportDetail reportView2)
{
// I break here and inspect reportView2. CaTypes is empty, AllCaTypes is null,
// and SelectedCaTypes does not show up at all in the inspector.
if (ModelState.IsValid)
{
CapService.Save2(reportView2);
}
else
{
return View("ReportDetail", reportView2);
}
return Redirect("/Report/Search");
}
Thanks!
Mike
Here's an excerpt from the View Model:
public class ViewReportDetail
{
public List<CaType> CaTypes { get; set; }
public List<CaType> AllCaTypes { get; set; }
public int[] SelectedCaTypes { get; set; }
}
Here's the multiselect widget in the view (strongly type as ViewReportDetail):
@using (Html.BeginForm("Save", "Report", FormMethod.Post))
{
@(Html.Kendo().MultiSelect()
.Name("CaTypes")
.DataTextField("Description")
.DataValueField("Id")
.BindTo(Model.AllCaTypes)
.Value(Model.SelectedCaTypes)
)
}
Here's the controller for the save (not much to see here):
public ActionResult Save(ViewReportDetail reportView2)
{
// I break here and inspect reportView2. CaTypes is empty, AllCaTypes is null,
// and SelectedCaTypes does not show up at all in the inspector.
if (ModelState.IsValid)
{
CapService.Save2(reportView2);
}
else
{
return View("ReportDetail", reportView2);
}
return Redirect("/Report/Search");
}
Thanks!
Mike