Skip to main content

Work with Pagination

Set and get the active page​

Use the setPage() method to set the active page in a widget. The method takes the index of a page as a parameter:

pagination.setPage(0);

The getPage() method returns the index of the active page:

const pageIndex = pagination.getPage();
// -> 3

Related sample: Pagination. Get / set page index

Set and get the number of items per page​

Use the setPageSize() method to set the number of items that the widget displays on each page. Pass the number of items as a parameter:

pagination.setPageSize(24);

Use the getPageSize() method to get the number of items per page:

pagination.getPageSize();
// -> 22

Related sample: Pagination. Get / set page size

Get the total number of pages​

The getPagesCount() method returns the total number of pages:

const totalPages = pagination.getPagesCount();
// -> 10

Related sample: Pagination. Get page count