[英]Kendo Grid DataSource error handler not firing
有一個來自 JQuery 的劍道讀取呼叫,如下所示:
var dataSource = new kendo.data.DataSource({
error: function (e) {
if (e.status === "error") {
this.cancelChanges();
showToast("Error Occurred", e.xhr.responseText, "exclamation-circle", "red");
var grid = $('#grid').data('kendoGrid');
grid.dataSource._data = self.formatData(grid.dataSource.data());
grid.refresh();
}
},
requestEnd: onRequestEnd,
transport: {
read: {
type: "GET",
dataType: "json",
url: '/api/user/getall'
},
destroy: {
url: function (data) {
return "api/user/delete/" + data.RecordKey;
},
type: "delete",
dataType: "json"
},
parameterMap: function (data, operation) {
return kendo.stringify(data);
}
},
服務器確定用戶未授權並返回以下內容
...
return new ContentResult()
{
StatusCode = 401,
Content = "No Access"
};
...
數據源中的錯誤blodk不會觸發? 不知道我錯過了什么。
似乎問題出在參數映射定義上,特別是在讀取操作上執行 function 時
parameterMap: function (data, operation) {
if (operation != "read") {
return kendo.stringify(data);
}
}
通過上述更新和模擬 401 響應,錯誤事件按預期觸發 -示例。
發現我的問題,在我的 requestEnd 塊中開始拋出錯誤。 更正了,錯誤正在觸發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.