The Kendo UI Ajax Binding documentation at Ajax Binding describes passing multiple data parameters to an Action method but it does not address passing arrays like MultiSelect values.
In the example below, if multisel is set to a string like "237896", the controller receives sitesFilter="237896". But if multisel is set to the MultiSelect value as shown below, the controller receives sitesFilter = null.
What is the proper way to send all of the MultiSelect values to the Action method using the MVC wrapper?
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("Documents_Read", "Document")
.Type(HttpVerbs.Post)
.Data("getCriteria"))
function getCriteria() {
var multisel = $("#sites").data("kendoMultiSelect").value();
return {
sitesFilter: multisel
};
}
public ActionResult Documents_Read([DataSourceRequest] DataSourceRequest request, string sitesFilter=null)
{
return Json(GetDocuments(sitesFilter).ToDataSourceResult(request), JsonRequestBehavior.DenyGet);
}
EDIT: getCriteria should convert the data to a string as shown below:
function getCriteria() {
var multisel = $("#sites").data("kendoMultiSelect").value().toString();
return {
sitesFilter: multisel
};