简体   繁体   English

MVC中的Kendo UI网格处理错误

[英]Kendo UI Grid handling error in MVC

I am using the Kendo UI grid via the MVC Helper object. 我通过MVC Helper对象使用Kendo UI网格。 If an error occurs in the ajax call (ie. web server is not available), the request returns an error code, however the Kendo UI grid does not respond and just continues to act as though there is no data being returned. 如果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")))

The MVC event is below: 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;
        }
    }

Is there a way to have the Kendo UI grid redirect the page to the error page on a failed call? 有没有办法让Kendo UI网格在失败的呼叫中将页面重定向到错误页面? I know I can do it with an ajax call, but I would rather use the Kendo UI MVC Helper functionality. 我知道我可以通过ajax调用来做到这一点,但是我更愿意使用Kendo UI MVC Helper功能。

Is there a way to do this as a global error handler that will apply to all ajax calls? 有没有办法作为全局错误处理程序来执行此操作,该错误处理程序将应用于所有ajax调用?

For handling errors with the Kendo UI Grid have a look at this question Kendo: Handling Errors in Ajax Data Requests 有关使用Kendo UI Grid 处理错误的信息,请查看以下问题Kendo:处理Ajax数据请求中的错误

You have to add an event to the datasource that will handle the error. 您必须将一个事件添加到将处理该错误的数据源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM