MinSIL MinSIL - 6 months ago 74
jQuery Question

Kendo MultiSelect Cannot read property 'value'

It is my PartialView:


<div class="form-group">
@Html.LabelFor(model => model.securities, htmlAttributes: new { @class = "control-label col-md-2"})
<div class="col-md-10">

.DataValueField("value")Product to be used by the multiselect as a value.
.HtmlAttributes(new { style = "width:350px; height:350px", @id = "prd" })
.DataSource(source =>
source.Read(read =>
read.Action("GetLogin", "IT_Inventory");
.ItemTemplate("<span><h3 style=\"font-size: 1.2em;font-weight: normal;margin: 0 0 1px 0;padding: 0;\">#: data.label #</h3><p style=\"margin:0;padding:0;font-size: .8em; \">#: data.desc #</p></span>")

My button:

<button type="button" id="btnSave" class="btn btn-success btn-lg">Save </button>

My JS:

$("#btnSave").click(function (e) {
type: 'POST',
url: '@Url.Action("SignIT", "IT_Inventory")',
data: JSON.stringify({ productMultiSelect: $("#productMultiSelect").data("kendoMultiSelect").value(), id: $("#id").val(), SomeBooleanProperty: false }),
dataType: 'json',
contentType: 'application/json',
success: function (data) {
if (data == true) {
else {
error: function () {
alert("An error has occured!!!");

When I try post to controller I am getting
Uncaught TypeError: Cannot read property 'value' of undefined
. For id and SomeBooleanProperty is ok.
When I use submit form is ok.
I should post data to controller list of productMultiSelect?


Looks like you havn't initialize you kendoMultiSelect, or it's in another div;

Check to see it:

console.log($("#productMultiSelect").length); //should be at least 1, if 0, then you initialized kendo in come other div


console.log($("#productMultiSelect").data("kendoMultiSelect")); //should be an object - if undefined, then you have not initialized kendo