I have a problem with the Kendo grid pager misbehaving after loading new data into a grid. The grid is loaded when the page loads, configured as follows:
@(Html.Kendo().Grid<MyModel>()
.Name("Grid")
.Columns(columns =>
{
//snipped
})
.Scrollable()
.Sortable(sort => sort.Enabled(true))
.Pageable(pager => pager.PageSizes(new int[] {10, 25, 50, 100}))
.Events(events => events.DetailExpand("detailExpand").DetailCollapse("detailCollapse").DataBinding("onDataBinding"))
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Sort(sort => sort.Add(Model.sort).Order(Model.Direction))
.PageSize(Model.PageSize)
.Events(events=>events.Error("onError"))
.Read(read => read.Action("Summary", "Summary").Data("getFilterModel")))
.Events(events => events.DataBound("dataBound"))
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
);
I have some controls on the page that serve as filters for the grid content. the getFilterModel function returns the values of those filters. When the user clicks the "Filter" button, I call read on the grid data source.
<button class="k-button" id="get" type="button" onclick="$('#Grid').data('kendoGrid').dataSource.read();return false;">Filter</button>
This works OK on initial page load, and if I reload the grid with a number of rows <= the original number of rows. If I reload with a larger number of rows, the pager shows the correct count. But, if I try to click to advance to the next page, the pager reverts to showing 1 page only, and the grid shows empty.
Example: initial load contains 3 records, page size 25. Pager shows 1 page. OK. Change filters so the grid loads 42 rows. Pager shows 2 pages, set to page 1, and "1-25 of 42 items". Click to advance to page 2; grid shows no rows, pager shows 1 page and "26-25 of 25 items"
Does the pager need to be explicitly reset somehow?
This is an older version of Kendo MVC...DLL shows version 2013.3.1119.340.