MVC中的Kendo UI Grid处理错误

sev*_*dcg 5 ajax jquery asp.net-mvc-4 kendo-ui kendo-grid

我通过MVC Helper对象使用Kendo UI网格.如果ajax调用中发生错误(即Web服务器不可用),请求将返回错误代码,但是Kendo UI网格不会响应,只是继续表现为没有返回数据.

@(Html.Kendo().Grid<ProcessInformation>()
              .Name("Grid")
              {Edited for brevity}
              .DataSource(datasource => datasource.Ajax()
                  .Read(read => read.Action("SearchProcesses", "SystemProcess")
                      .Data("searchSerialize"))
                  .PageSize(10)
              ).Name("ResultsGrid").Events(events => events.DataBound("gridOnBound")))
Run Code Online (Sandbox Code Playgroud)

MVC活动如下:

public ActionResult SearchProcesses(
        [DataSourceRequest] DataSourceRequest request, string startDate, string endDate, string status, int dataProcessType)
    {
        try
        {
            //does the search and returns the object
        }
        catch (Exception e)
        {
            this.log.ErrorException("Error Encountered in WebInternal.SearchProcesses()", e);
            var result = new JsonResult
            {
                Data = new { Redirect = "../Error/Unexpected" }, 
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
            return result;
        }
    }
Run Code Online (Sandbox Code Playgroud)

有没有办法让Kendo UI网格在失败的呼叫中将页面重定向到错误页面?我知道我可以通过ajax调用来实现它,但我宁愿使用Kendo UI MVC Helper功能.

有没有办法将此作为一个适用于所有ajax调用的全局错误处理程序?

asy*_*ult 5

对于使用Kendo UI Grid 处理错误,请查看此问题Kendo:处理Ajax数据请求中的错误

您必须向将处理错误的数据源添加事件.