0
我試圖將項目添加到我的Kendo DataSource
,但我不斷收到以下錯誤,每當我嘗試添加:劍道dataSource.add - 類型錯誤:o是未定義
TypeError: o is undefined - kendo.all.min.js (line 50, col 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
都包含值,所以我完全失去了這個錯誤。