How to show a message when all items have been loaded ?

Hello,
Is it possible to show a message under a repeater once every item has been loaded, such as “No more items found” ?

Thanks.

Yes, you could, but in code. You would get the .count of your query in code, put a textbox underneath the repeater and put its text to something like “Loaded n out of n. No more matches found.” where n is the count.

Hi,

Thanks for the answer but I’m a real begginer at this, could you please tell me what code to put ?

Thanks !

Sure. First, you do the query in code ( inside the $w.onReady)

var resultCount;
wixData.query(“YourCollectionName”)
// just examples of selecting for = and >
.eq(“crit1”, arg1)
.gt(“crit2”, arg2)
.find()
.then((results) => {
resultCount = results.totalCount;
$w(“#repeater1”).data = results.items;
})
.catch((err) => {
let errorMsg = err;
});

Then you fill the repeater with data like:
$w(“#repeater1”).onItemReady(($w, itemData) => {

here you do all your coding, formatting, checking
}

and at the very end you fill you textbox.text with the content of resultCount .

This example assumes you do the whole query in code, so you do not need to put everything in a dataset.onReady, like most examples. Remember that a dataset is interface glue if you do not code.
If you do, you do not need a dataset (so delete it from your page, or it will go wrong, you will get 2 queries: one from the dataset and one from the code).
In my first answer I hinted at doing a second query, just doing a .count, but here we now do it all in one.

Look up the API doc if you run into trouble: finding a bug yourself is always a better learning experience then asking for help without sweating :-).

Thanks, but I didn’t really understand it.

For now my #repeater2 is connected to #dynamicDataset and is set to display 20 items, by chronological order.

What should I put in the onReady code ?

The text showing the “no more results found” is #text73

Thanks !

help, I only need this before publishing my website :slight_smile:

refresh