5

I am using the Kendo UI grid via the MVC Helper object. 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.

@(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:

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? I know I can do it with an ajax call, but I would rather use the Kendo UI MVC Helper functionality.

Is there a way to do this as a global error handler that will apply to all ajax calls?

sevargdcg
  • 295
  • 2
  • 8
  • 17
  • I believe you can certainly create a handler for ajax calls but as you said the trick will be getting the grid to do something on an error since it is initiating the request. I don't believe you can return a redirect from an ajax call that will bypass the grid. – asymptoticFault Aug 22 '13 at 17:45
  • This might be helpful http://stackoverflow.com/questions/13653662/kendo-handling-errors-in-ajax-data-requests – asymptoticFault Aug 22 '13 at 18:00
  • That ended up working. If you can put that in an answer that would be great. – sevargdcg Aug 23 '13 at 17:06

1 Answers1

5

For handling errors with the Kendo UI Grid have a look at this question Kendo: Handling Errors in Ajax Data Requests

You have to add an event to the datasource that will handle the error.

Community
  • 1
  • 1
asymptoticFault
  • 4,491
  • 2
  • 19
  • 24