Kendo MultiSelect无法读取属性'值'
Kendo MultiSelect Cannot read property 'value'
这是我的PartialView:
.......
<div class="form-group">
@Html.LabelFor(model => model.securities, htmlAttributes: new { @class = "control-label col-md-2"})
<div class="col-md-10">
@(Html.Kendo().MultiSelect()
.Name("productMultiSelect")
.DataTextField("label")
.DataValueField("value")Product to be used by the multiselect as a value.
.HtmlAttributes(new { style = "width:350px; height:350px", @id = "prd" })
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetLogin", "IT_Inventory");
})
.ServerFiltering(false);
})
.Value(ViewBag.SelectedItem2)
.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>")
)
</div>
</div>
我的按钮:
<button type="button" id="btnSave" class="btn btn-success btn-lg">Save </button>
我的JS:
<script>
$("#btnSave").click(function (e) {
e.preventdefault();
$.ajax({
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) {
$("#onInsert").data("kendoWindow").close();
}
else {
alert("Error!");
}
},
error: function () {
alert("An error has occured!!!");
}
});
});
</script>
当我尝试张贴到控制器时,我得到了Uncaught TypeError: Cannot read property 'value' of undefined
。对于id和SomeBooleanProperty是可以的。当我使用提交表格是可以的。我应该将数据发布到产品的控制器列表MultiSelect?
看起来您还没有初始化kendoMultiSelect,或者它在另一个div中;
查看:
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
console.log($("#productMultiSelect").length); - 0
console.log($("#productMultiSelect").data("kendoMultiSelect")); - undefined
非常有趣和奇怪。
此PartialView位于KendoWindow中。
相关文章:
- TypeError:无法读取属性'推'未定义的JavaScript
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 未捕获的类型错误:无法读取属性'删除'的未定义
- AngularJS指令出错-无法读取属性'编译'的未定义
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- angularjs无法读取未定义的属性then
- 无法读取属性'材料'未定义的Three.js
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- Soundcloud Javascript SDK 3.0-回调无法读取属性'connectCallback
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- JavaScript承诺-无法读取属性'那么'的未定义
- Javascript Float32数组抛出无法读取属性'0'即使数组定义良好,也为null
- 未捕获的类型错误:无法读取属性'中止'的未定义
- 角度推入数组给出:TypeError:无法读取属性'推'的未定义
- http/rxjs catch回调中的Angular 2重定向导致TypeError:无法读取属性'订阅'
- 角度输入模型有条件地从一个属性读取,写入另一个属性