如何刷新 Kendo UI 网格 [英] How to refresh the Kendo UI grid
本文介绍了如何刷新 Kendo UI 网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试刷新 Kendo UI 网格,但尚未成功.有人能告诉我我错过了什么或我做错了什么吗?
I am trying to refresh a Kendo UI grid but have not yet been successful. Would anybody please advise what I missed or what I did wrong?
我有以下代码:
.cshtml:
$('#btnRefresh').click(function (e){
$.ajax({
type: 'POST',
url: "@(Url.Content("~/Administration/RefreshAll/"))",
success: function () {
$("#Product").data("kendoGrid").dataSource.read();
$('#Product').data('kendoGrid').refresh();
//grid.refresh();
location.reload(true);
},
error: function (){
$("#btnRefresh").removeAttr('disabled');
}
});
});
控制器:
public ActionResult RefreshAll([DataSourceRequest] DataSourceRequest request)
{
db.ProcessAll();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
return View();
}
推荐答案
你的脚本应该是
$('#btnRefresh').click(function (e){
var grid = $("#Product").data("kendoGrid");
grid.dataSource.page(1);
grid.dataSource.read();
});
在您的控制器中添加引用到
使用Kendo.Mvc.UI;
使用 Kendo.Mvc.Extensions;
你的ActionResult应该是
public ActionResult RefreshAll([DataSourceRequest] DataSourceRequest request)
{
//assuming db.ProcessAll() will return a list object
return Json(db.ProcessAll().ToDataSourceResult(request));
}
这篇关于如何刷新 Kendo UI 网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文