Kendo Grid DataSource错误处理程序未启动



从JQuery进行Kendo Read调用,如下所示:

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没有激发?不确定我错过了什么。

问题似乎与parameterMap定义有关,特别是在读取操作上执行函数时

parameterMap: function (data, operation) {
if (operation != "read") {
return kendo.stringify(data);
}
}

有了上面的更新和mock 401响应,错误事件就会按预期触发——例如。

发现我的问题,在requestEnd块中开始抛出时出错。更正了这一点,错误正在启动。

最新更新