我正在尝试向Kendo DataSource
添加项目,但每当我尝试添加时,我都会收到以下错误:
TypeError:o未定义 - kendo.all.min.js(第50行,第23446行)
当我尝试使用dataSource.add()
方法时会发生这种情况。
sectionNotesDataSource: new kendo.data.DataSource({
transport: {
read: {
url: "/baa/baa/GetNotes",
dataType: "json",
type: "GET",
data: {
Id: $("#Id").val()
}
},
create: {
url: "/baa/baa/CreateNote",
dataType: "json",
type: "POST"
},
parameterMap: function (data, operation) {
if (operation === "update" || operation === "create") {
data.CreateDate = _dateToString(data.CreateDate);
data.LastModDate = _dateToString(data.LastModDate);
}
return data;
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false, nullable: true },
BaaId: { type: "number", editable: false, nullable: false },
BaaSectionId: { type: "number", editable: false, nullable: false },
Body: { type: "string", editable: true },
}
}
}
}),
onNewNote: function (e) {
var baaId = $(e.currentTarget).data("baaId");
var baaSectionId = $(e.currentTarget).data("baasection");
var noteList = $(e.target).closest(".baa-section-notes").find(".section-note-list").data("kendoListView");
$("#NoteSave").on("click", function() {
var body = editor.value();
noteList.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body });
}
});
我一直试图找出导致过去几个小时出现此错误的原因,但似乎无法弄明白。
BaaId
,BaaSectionId
和Body
都包含值,因此我完全迷失在此错误中。
答案 0 :(得分:0)
我最终解决了我的问题。
我改变了行
noteList.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body });
到
noteList.dataSource.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body });