[英]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.