Search.../

getTotalPageCount( )

Gets the number of pages in the dataset.

Description

The number of pages in a dataset is the number of total items divided by the page size. If there are any left over items, one more page is added.

For example, if you have 20 items and your page size is 6, you have 4 pages. The first 3 pages have 6 items each and the last page has 2 items.

Note:

A dataset needs to load its data before you call its getTotalPageCount() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call getTotalPageCount() inside the page’s onReady() event handler, the dataset might not be ready yet.

To call getTotalPageCount() as soon as possible after a page loads, use the dataset's onReady() function inside the page’s onReady() event handler to ensure that both the page and the dataset have finished loading.

Syntax

function getTotalPageCount(): number

getTotalPageCount Parameters

This function does not take any parameters.

Returns

The number of pages in the dataset.

Return Type:

number
Mixed in from:wix-dataset.Dataset

Was this helpful?

Get the number of pages in the dataset

Copy Code
1let pageCount = $w("#myDataset").getTotalPageCount(); // 4