Kendo ui 如何刷新剑道UI网格

Kendo ui 如何刷新剑道UI网格,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我正在尝试刷新剑道UI网格,但尚未成功。谁能告诉我我错过了什么或我做错了什么 我有以下代码: .cshtml: $('#btnRefresh').click(function (e){ $.ajax({ type: 'POST', url: "@(Url.Content("~/Administration/RefreshAll/"))", success: functio

我正在尝试刷新剑道UI网格,但尚未成功。谁能告诉我我错过了什么或我做错了什么

我有以下代码:

.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
您的操作结果应该是

public ActionResult RefreshAll([DataSourceRequest] DataSourceRequest request)
        {
            //assuming db.ProcessAll() will return a list object
            return Json(db.ProcessAll().ToDataSourceResult(request));
        }

public void ProcessAll(),因此我无法作为JSONY返回您需要将列表对象传递给模型。@谢谢,但这会导致“TypeError:$(…)。数据(…)未定义”错误。我也看了很多页,尝试了这个解决方案的不同变体,但仍然得到相同的错误。有什么想法吗?@chrisrof检查你的选择器是否有网格