Thursday, 22 August 2013

Kendo UI Grid handling error in MVC

Kendo UI Grid handling error in MVC

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?

No comments:

Post a Comment