由于我尝试在 kendoui 论坛上写作,但我得到的答案是“购买许可证”以报告错误,我想问是否有人在使用 kendoGrid 2013.1.319 时遇到过同样的问题。由于我在“周日测试应用程序”中使用它,所以一点也不着急!
我在剑道论坛上的原始信息是:
你好呀,
我已经用最新版本更新了剑道网格,突然间我的应用程序面临数据操作问题。问题似乎位于客户端,因为我正确接收了对 GET、PUT、POST 和 DELETE 动词的请求,但网格没有更新其状态。
我正在通过 API 服务使用 ASP.NET MVC 4 OData 实现。
例如:如果我删除 2 行并按保存,则会进行 DELETE 调用,客户端网格会隐藏这些行,但如果我再次按保存,则会不断调用删除。
同样的问题是在更新/创建时,单元格仍然带有红色角,保存后,数据仍然像第一次一样提交。
我注意到当我收到关于 dataSource 的回调时:
requestEnd: function (e) {
if (e.type === "update" || e.type === "create") {
// Refresh data after changes
this.read();
}
}
插入或更新记录时,e.type 始终未定义。
这是我的数据源配置:
dataSource: {
type: 'odata', // <-- Include OData style params on query string
transport: {
read: {
url: $("#contactsGrid").attr("data-api-crud"),
dataType: "json", // <-- The default is "jsonp".
type: "GET"
},
update: {
url: $("#contactsGrid").attr("data-api-crud"),
dataType: "json", // <-- The default is "jsonp".
type: "POST"
},
create: {
url: $("#contactsGrid").attr("data-api-crud"),
dataType: "json", // <-- The default is "jsonp".
type: "PUT"
},
destroy: {
url: function (data) {
return $("#contactsGrid").attr("data-api-crud") + "/" + data.Id;
},
dataType: "json", // <-- The default is "jsonp".
type: "DELETE"
},
parameterMap: kendo.data.transports.odata.parameterMap
},
schema: {
// The array of repeating data elements (items)
data: "Results",
// The total count of records in the whole dataset. used for paging.
total: "Count",
model: {
id: "Id",
fields: {
Dealer: { type: "string", editable: true },
Address: { type: "string", editable: true }
}
}
},
pageSize: 50,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
requestEnd: function (e) {
if (e.type === "update" || e.type === "create") {
// Refresh data after changes
this.read();
}
}
}