Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh the Kendo UI grid

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?

I have the following code:

.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');
                }
            });


      });

Controller:

public ActionResult RefreshAll([DataSourceRequest] DataSourceRequest request)
        {
            db.ProcessAll();
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            return View();
        }
like image 939
Spidey Avatar asked May 09 '13 21:05

Spidey


People also ask

How do you refresh a kendo scheduler?

I hence call the following refresh code: $("#scheduler"). data("kendoScheduler"). refresh();


1 Answers

your script should be

$('#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;

your ActionResult should be

public ActionResult RefreshAll([DataSourceRequest] DataSourceRequest request)
        {
            //assuming db.ProcessAll() will return a list object
            return Json(db.ProcessAll().ToDataSourceResult(request));
        }
like image 127
HaBo Avatar answered Oct 01 '22 07:10

HaBo