Work with Pagination
Setting/getting the active page
It is possible to set the active page in a widget via Pagination API, i.e. with the help of the setPage() method. It takes the index of a page as a parameter:
pagination.setPage(0);
You can also identify what page is currently active by using the getPage() method. It will return the index of the active page:
const pageIndex = pagination.getPage();
// -> 3
Related sample: Pagination. Get / set page index
Setting/getting count of items per page
You can define the size of the widget page, i.e specify the number of items to be displayed on each page of the widget via the setPageSize() method. Pass the necessary number of items as a parameter to the method:
pagination.setPageSize(24);
Use the getPageSize() method to get the count of items displayed per page:
pagination.getPageSize();
// -> 22
Related sample: Pagination. Get / set page size
Getting total number of pages
You can get the total number of pages by applying the getPagesCount() method:
const totalPages = pagination.getPagesCount();
// -> 10
Related sample: Pagination. Get page count