hi.
I have a repeater with data i load into it with code. (not connected to dataset because i need to query the data by _updatedDate and its not exist in dataset element).
i noticed the repeater show only 50 items max.
how can i add more repeater’s items when clicked on a button?
Hey
When you ise wixData.query it will by default get 50 items. If you add the .limit(1000) it will get the first 1000 records from your data collection. If you want to use a Load More button you need to utilize the .skip function in wixData.query to read the first 50 and when clicking on Load More rerun the query but add .skip(50) and you will get the next 50 records and then you keep on adding 50.
Like this
export function getPagedData(offset) {
wixData.query("myCollection")
.skip(offset)
.find()
.then( (results) => {
let items = results.items;
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
}
// use it like this
let pageNr = 1;
let pageSize = 50;
let allItems = getPagedData(pageNr*pageSize); // Will get first 50 records
// then when someone clicks your button
pageNr = pageNr + 1;
let allItems = getPagedData(pageNr*pageSize); // will get next 50
Read more here:
It works with filtered data as well?
Example
wixData.query(“myCollection”)
.eq(“name”, namevar)
.skip(offset)
.find()
.then( (results) => {
let items = results.items;
} )
?
Ok great. I will try. Thanks