This is a migrated thread and some comments may be shown as answers.

Get current page

1 Answer 1948 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hello
Top achievements
Rank 1
Hello asked on 21 Apr 2020, 01:54 PM

I'm trying to get current page from the pager component as I need to pass the incremented value that into REST service backend. I can get hold of it in the template code: 

<ng-template kendoPagerTemplate let-totalPages="totalPages" let-currentPage="currentPage">
<kendo-pager-prev-buttons></kendo-pager-prev-buttons>
<kendo-pager-input></kendo-pager-input>
<kendo-pager-info></kendo-pager-info>
<kendo-pager-next-buttons></kendo-pager-next-buttons>
<kendo-pager-page-sizes ></kendo-pager-page-sizes>
<div>
current page {{currentPage}}
</div>

</ng-template>>

 

But I need to access it in the component code in pageChange event so that I can call the rest service with correct page number. How can I do that? The pageChange only has skip and take properties but I'm trying to figure out current page.

All data comes from external API.

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 23 Apr 2020, 08:08 AM

Hi,

I see that you have also opened a private support thread on this topic. Thus I will proceed with pasting the same answer here as well:

"I will begin by providing some general information. The pageChange event is fired each time when the user changes the page of the Grid. The event returns a PageChangeEvent object that contains skip and take properties which determines the portion of items shown on every page. Please check the following article from our documentation:

https://www.telerik.com/kendo-angular-ui/components/grid/paging/

In order to capture the currently selected page number, the index needs to be calculated. Such an example is demonstrated in the following StackBlitz:

https://stackblitz.com/edit/angular-xolrsc?file=app/app.component.ts

Basically, if you want to go on a specific page programmatically, the skip and take properties need to be modified. For example, if the pageSize is set to 10 and you need to programmatically navigate to the 4 page, the skip option needs to be 30 and the take property to 10.

Let me know if I am missing something or if any further assistance is required for this case."

Please let us know in case further assistance is required for this case. Thank you.

Regards,
Svetlin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Hello
Top achievements
Rank 1
Answers by
Svet
Telerik team
Share this question
or