繁体   English   中英

MVC中的Kendo UI网格处理错误

[英]Kendo UI Grid handling error in MVC

我通过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")))

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

有没有办法让Kendo UI网格在失败的呼叫中将页面重定向到错误页面? 我知道我可以通过ajax调用来做到这一点,但是我更愿意使用Kendo UI MVC Helper功能。

有没有办法作为全局错误处理程序来执行此操作,该错误处理程序将应用于所有ajax调用?

有关使用Kendo UI Grid 处理错误的信息,请查看以下问题Kendo:处理Ajax数据请求中的错误

您必须将一个事件添加到将处理该错误的数据源。

暂无
暂无

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

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