javascriptpaginationkendo-uikendo-griddatasource

Refreshing KendoUI Grid - pager broken


I have created a simple Kendo UI grid with paging. Now I want to refresh my grid with some new data. Im using the setDatasource to attach the new data to the grid and then refresh to refresh the grid. Works fine except that the pager stops working. It will just give me a no-items-in-the-grid message.

I created a jsFiddle to demonstrate what I mean:

http://jsfiddle.net/DXgYu/

And here is the code I use to refresh the grid:

var grid = $("#grid").data("kendoGrid");
var ds = setds();
grid.setDataSource(ds);
grid.refresh();

In my example I wont be changing the data but that doesn't matter. If you click the button it will not refresh the pager the correct way and I have no clue how to get the pager to update too. Hopefully someone can help me! It's probably something small but I just can't find anywhere how to access the grid pager.

Thanks in advance.


Solution

  • The Grid's .setDataSource() function expects an actual kendo.data.DataSource not just an object. Change your .setds() function to return a DataSource:

    function setds() {
        return new kendo.data.DataSource({
            ...
        });
    }