Search code examples
kendo-uikendo-gridkendo-asp.net-mvc

Kendo Grid DataSource error handler not firing


Have a Kendo Read Call from JQuery as follows:

 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);
        }
    },

The server determines user unauthorized and returns the following Content

...

        return new ContentResult()
        {
            StatusCode = 401,
            Content = "No Access" 
        };

...

The errors blodk in the in the datasource does not fire? Not sure what I am missing.


Solution

  • Found my issue I had an error begin throw in my requestEnd block. Corrected that and error is firing.