Hello,
I'm using a multiselect and i have a problem returning the value of the multiselect to the controller while using a ajax call.
Model
Controller
Ajax call
If i run this with an empty multiselect i get an empty string, but with values it returns null in the controller. Also the alert before the ajax call returns all the values perfectly, the version that i'm currently using 2013.3.1119.545
I'm using a multiselect and i have a problem returning the value of the multiselect to the controller while using a ajax call.
@(Html.Kendo().MultiSelect()
.Name("BaPaymentMachine")
.Placeholder("Please choose BA")
.DataTextField("Id")
.DataValueField("Id")
.DataSource(ds => ds.Read("GetAllBaPayment", "Report"))
.HtmlAttributes(new { @style = "width:200px;" }))
public class SearchViewModel
{
public List<string> BaPaymentMachine { get; set; }
}
[HttpGet]
[OutputCache(Duration = 0)]
public ActionResult _GetReportPartial(SearchViewModel model)
{
do stuff to model
return PartialView(model);
}
var ba = $("#BaPaymentMachine").val();
alert("ba:" + ba);
$.ajax({
type: "GET",
url: '@Url.Action("_GetReportPartial", "Report")',
data: { BaPaymentMachine: ba },
cache: false,
success: function (data) {
var newBox = "<
div
id
=
'reportmap'
class
=
'width:100%'
>" + data + "</
div
>";
$("#result").html(newBox);
$(".loaderrepport").fadeOut("slow");
},
error: function () {
showerror("There was a problem getting the values, please try again.");
$(".loaderrepport").fadeOut("slow");
}
});
});