如何刷新Kendo UI网格 [英] How to refresh the Kendo UI grid

查看:89
本文介绍了如何刷新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();
      });

在您的控制器中

in your controller add references to

  • using Kendo.Mvc.UI;
  • using Kendo.Mvc.Extensions;
  • using Kendo.Mvc.UI;
  • using Kendo.Mvc.Extensions;

您的动作结果应为

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

这篇关于如何刷新Kendo UI网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆