This is a migrated thread and some comments may be shown as answers.
AngularJs Grid - need to update page number without causing request to server
6 Answers 28 Views
This is a migrated thread and some comments may be shown as answers.
Itay
Top achievements
Rank 1
Itay asked on 13 Jan 2016, 01:21 PM

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

Sort by
0
Dimo
Telerik team
answered on 15 Jan 2016, 11:43 AM
Hello Itay,

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
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Itay
Top achievements
Rank 1
answered on 15 Jan 2016, 07:33 PM
Hello Dimo,

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
0
Benjamin
Top achievements
Rank 1
answered on 18 Jan 2016, 03:00 PM

Hi,

 in Combobox this behaviour could be achieved by using the value mapper function. I'm not sure if its possible in grid too.

0
Dimo
Telerik team
answered on 19 Jan 2016, 08:44 AM
Hello,

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
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Syleps
Top achievements
Rank 1
answered on 27 Aug 2017, 08:39 AM

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.

0
Dimo
Telerik team
answered on 29 Aug 2017, 08:51 AM
Hello Syleps,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Itay
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Itay
Top achievements
Rank 1
Benjamin
Top achievements
Rank 1
Syleps
Top achievements
Rank 1
Share this question
or