I seem to be having a problem posting the selected values from my Kendo Multiselect widget to an action on my controller. I've never had this issue before and as far as I know I am doing everything right, but something is obviously causing an issue.
I have this input on my view:
<
input
id
=
"ProductHandlingTypes"
name
=
"ProductHandlingTypes"
style
=
"width: 100%"
/>
Here is my viewmodel:
public
class
BuyerProfileViewModel
{
public
string
UserId {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
int
BuyerTypeId {
get
;
set
; }
public
string
Address {
get
;
set
; }
public
string
City {
get
;
set
; }
public
string
State {
get
;
set
; }
public
string
Zipcode {
get
;
set
; }
public
string
Description {
get
;
set
; }
public
List<
int
> ProductHandlingTypes {
get
;
set
; }
public
bool
Producer {
get
;
set
; }
}
JavaScript:
$(
"#ProductHandlingTypes"
).kendoMultiSelect({
placeholder:
"-- Select Type(s) --"
,
dataTextField:
"Name"
,
dataValueField:
"Id"
,
dataSource:
new
kendo.data.DataSource({
transport: {
read: {
url:
"/Helper/GetProductHandlingTypes"
,
dataType:
"json"
,
type:
"GET"
}
}
})
});
$(
"#btnSave"
).on(
"click"
,
function
(e) {
e.preventDefault();
var
formCreate = $(
".form-register-buyer"
);
formCreate.validate();
if
(formCreate.valid()) {
var
options = {
url: $(formCreate).attr(
"action"
),
type: $(formCreate).attr(
"method"
),
data: $(formCreate).serialize()
};
$.ajax(options)
.done(
function
(data) {
if
(data.success ===
true
) {
window.location.href = data.redirectTo;
}
else
{
toastr.options = {
"postiionClass"
:
"toast-bottom-full-width"
};
toastr.error(data.message,
"Uh, Oh!"
);
}
});
}
});
And a snippit of my controller:
[HttpPost]
public
ActionResult BuyerProfile(BuyerProfileViewModel model)
{
if
(ModelState.IsValid)
{
// do stuff here
}
}
All of the rest of the values post to the controller just fine. But when I hover over the model this is what I see for "ProductHandlingTypes" (I've attached a screenshot)