我遇到了剑道调度程序的问题。我和AngularJS一起使用它。 当我创建一个事件并单击保存时,第一个创建窗口不会关闭,当我手动关闭它时,事件不存在。但是,如果我重新加载页面,那么事件会显示在那里,所以它会被保存到数据库中。
Scheduler dataSource:
var dataSource = {
transport: {
read: read,
create: create,
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
},
},
schema: {
model: {
id: "occurrenceId",
fields: {
occurrenceId: { from: "occurrenceId", type: "number" },
title: { from: "title", defaultValue: "No title", validation: { required: true } },
start: { type: "date", from: "start" },
end: { type: "date", from: "end" },
description: { from: "description" },
recurrenceId: { from: "RecurrenceID" },
recurrenceRule: { from: "RecurrenceRule" },
recurrenceException: { from: "RecurrenceException" },
isAllDay: { type: "boolean", from: "IsAllDay" }
}
}
}
};
这是创建功能:
function create(data) {
var occurrence = {
"title": data.data.title,
"start": data.data.start,
"end": data.data.end,
"description": data.data.description,
"recurrenceId": data.data.recurrenceId,
"recurrenceRule": data.data.recurrenceRule,
"recurrenceException": data.data.recurrenceException,
"isAllDay": data.data.isAllDay,
"ownerId": $scope.resource.id
}
$http({
method: 'POST',
url: '/api/occurrences',
data: JSON.stringify(occurrence),
contentType: "application/json"
}).success(function (response) {
response.data
});
}
答案 0 :(得分:0)
尝试从create function返回插入的数据(包括生成的ID)。在你的http帖子的成功之后,它似乎没有做任何有意义的事情。
来自Kendo-UI data source API reference:远程服务必须返回插入的数据项,并且必须设置配置为id的数据项字段。例如,如果数据项的id是ProductID,则"创建"服务器响应必须是[{" ProductID":79}]。