Sometimes my grid raises a request to server with page=1 but the server returns as a result page number 3.
I need to change the page number in the grid to 3 but without causing a new ajax request like happens with:
grid.data("kendoGrid").dataSource.page(pageNumber);
Thanks
6 Answers, 1 is accepted
Let me confirm that I understand you correctly - the Grid requests the items for page 1, but the server incorrectly returns the items for page 3 and this behavior is not caused by Kendo UI, right?
Changing the page number always triggers a request, because the Grid doesn't know that it has already received the data for the desired page by mistake. I am afraid I cannot suggest any workarounds in this case.
Regards,
Dimo
Telerik
We would like to set the grid to an initial position based on an item id without knowing the page number. Once the response page is displayed we’d like to user to continue paging as usual.
Here is the desired use-case in details. The initial request contains a filtered request where the actual page number is unknown. The desire is to get to a known item whose position is unknown and then let the user continue the paging process as she pleases. The server puts the page number in the response and we’d like to set this page to the grid, including the paging buttons value. We then would like to grid to act as usual. We manage to add the custom filtering parameter using transport/data function. What we fail to do is to set the page number to the grid, without causing the grid to trigger another request.
Is there a way to properly turn off auto-bind, setting the page and then turn auto-bind on again?
We hope there is an elegant way to get this use case work with a single server request.
Thanks
Hi,
in Combobox this behaviour could be achieved by using the value mapper function. I'm not sure if its possible in grid too.
The described Grid scenario requires the correct page number to be known in advance and the Grid DataSource to be paged to that particular page. In other words, use one custom Ajax request for the page number and then the Grid will use a standard read request for the data from that page.
Regards,
Dimo
Telerik
Hi,
I have a similar problem.
In my case I don't know at the start of my grid the number of records; either because this one is very fluctuating, or because the calculation of the count is too expensive in execution time (more than fetch n records)
So to have the pager, I return a count to maxint
But when user go to the end of data, we can detect that and know the real number of rows, that the server returns in the DataSourceResult (in ASP.Net)
The pager is then in an inconsistent situation where the currentPage > totalPages
To correct this, the current page number is specified via the pager.page (n) method, but this automatically restarts a databound that is not necessary.
Any solution ?
Regards.
The Kendo UI DataSource is designed to perform a request when the page is changed, and this cannot be prevented. You actually can prevent the request, but this will also cancel the page change in the pager's UI.
The only way to achieve the desired behavior is to use a custom DataSource transport:
http://docs.telerik.com/kendo-ui/framework/datasource/crud#local-or-custom-transport-crud-operations
In this case you will need to cache all received data on the client and when a "fake" request should be made, you will return the already available data from the desired page in the e.success() callback without an actual request.
Regards,
Dimo
Progress Telerik