【问题标题】:Kendo UI Grid handling error in MVCMVC 中的 Kendo UI Grid 处理错误
【发布时间】:2013-08-25 13:49:57
【问题描述】:

我正在通过 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 调用?

【问题讨论】:

  • 我相信你当然可以为 ajax 调用创建一个处理程序,但正如你所说的那样,诀窍是让网格对错误执行某些操作,因为它正在启动请求。我不相信您可以从绕过网格的 ajax 调用返回重定向。
  • 这最终奏效了。如果你能把它放在一个很好的答案中。

标签: jquery ajax asp.net-mvc-4 kendo-ui kendo-grid


【解决方案1】:

有关处理 Kendo UI Grid 的错误,请查看此问题 Kendo: Handling Errors in Ajax Data Requests

您必须向数据源添加一个事件来处理错误。

【讨论】:

    猜你喜欢
    • 2013-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多