Reloading/refreshing Kendo Grid

2019-01-05 09:41发布

How to reload or refresh a Kendo Grid using Javascript?

It is often required to reload or refresh a grid after sometime or after a user action.

23条回答
家丑人穷心不美
2楼-- · 2019-01-05 09:45

You can use

$('#GridName').data('kendoGrid').dataSource.read(); <!--  first reload data source -->

$('#GridName').data('kendoGrid').refresh(); <!--  refresh current UI -->
查看更多
别忘想泡老子
3楼-- · 2019-01-05 09:45

In a recent project, I had to update the Kendo UI Grid based on some calls, that were happening on some dropdown selects. Here is what I ended up using:

$.ajax({
        url: '/api/....',
        data: { myIDSArray: javascriptArrayOfIDs },
        traditional: true,
        success: function(result) {
            searchResults = result;
        }
    }).done(function() {
        var dataSource = new kendo.data.DataSource({ data: searchResults });
        var grid = $('#myKendoGrid').data("kendoGrid");
        dataSource.read();
        grid.setDataSource(dataSource);
    });

Hopefully this will save you some time.

查看更多
迷人小祖宗
4楼-- · 2019-01-05 09:45

An alternative way to reload the grid is

$("#GridName").getKendoGrid().dataSource.read();
查看更多
不美不萌又怎样
5楼-- · 2019-01-05 09:46

The default/updated configuration/data of the widgets is set to automatically bind to an associated DataSource.

$('#GridId').data('kendoGrid').dataSource.read();
$('#GridId').data('kendoGrid').refresh();
查看更多
叼着烟拽天下
6楼-- · 2019-01-05 09:46

The easiest way out to refresh is using the refresh() function. Which goes like:

$('#gridName').data('kendoGrid').refresh();

while you can also refresh the data source using this command:

$('#gridName').data('kendoGrid').dataSource.read();

The latter actually reloads the data source of the grid. The use of both can be done according to your need and requirement.

查看更多
Juvenile、少年°
7楼-- · 2019-01-05 09:49
$('#GridName').data('kendoGrid').dataSource.read();
$('#GridName').data('kendoGrid').refresh();
查看更多
登录 后发表回答