loadPage( )
Loads the specified page.
Description
The loadPage()
function returns a Promise that is resolved to
an array of the specified page's items when:
- The current item is saved in the collection (if necessary).
- The specified page of data is loaded.
- Any connected elements have been updated with the new data.
- The current item is updated to the first item in the loaded page.
The indices of the dataset's pages start at 1
.
Notes:
A dataset needs to load its data before you call its
loadPage()
function.Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call
loadPage()
inside the page’sonReady()
event handler, the dataset might not be ready yet.To call
loadPage()
as soon as possible after a page loads, use the dataset'sonReady()
function inside the page’sonReady()
event handler to ensure that both the page and the dataset have finished loading.When using a read-write dataset and linked input elements, calling any of the following functions will save any changes made in the linked input elements.
Syntax
function loadPage(pageIndex: number): Promise<Array<Object>>
loadPage Parameters
NAME
TYPE
DESCRIPTION
The index of the page to load.
Returns
Fulfilled - When the specified page has been loaded and any connected elements have been updated. Rejected - An error message.
Return Type:
Related Content:
Was this helpful?
1$w("#myDataset").loadPage(4)2 .then( (items) => {3 let firstItem = items[0];4 let fieldValue = firstItem.fieldName;5 } )6 .catch( (err) => {7 let errMsg = err.message;8 let errCode = err.code;9 } );
1$w.onReady( () => {2 $w("#myDataset").onReady( () => {3 $w("#myDataset").loadPage(4)4 .then( (items) => {5 let firstItem = items[0];6 let fieldValue = firstItem.fieldName;7 } )8 .catch( (err) => {9 let errMsg = err.message;10 let errCode = err.code;11 } );1213 } );1415} );