I’m currently having an issue resetting a dataset to only display the default “Number of Items to Display” after changing tabs and coming back.
The example in question can be found here: https://www.tobymcdowell.com/portfolio
Scrolling down on the All tab and clicking “See More” adds 9 items to the list using the loadMore() function.
Going on to different tabs does not refresh the amount of items visible from 18 (since “See More” was pressed) to 9 (the default amount of records displayed).
Returning to the “All” tab shows 18 items in the list, where I would prefer it be the default value
Is there a way to achieve this?
Here is my button code:
// Changes tab based on parameters, disables button pressed
export function SelectCategory($w, _prevSelection, filter, category)
{
$w(prvSelection).enable();
prvSelection = _prevSelection;
$w(_prevSelection).disable();
$w("#btnSeeMore").hide();
// Display preloader
ShowLoadingGif($w);
// Change filter
$w("#dataset1").setFilter(wixData.filter()
.contains(filter, category)
);
// Refresh and remove the preloader after completion
$w("#dataset1").refresh().then ( () => {
// Reset 'See More' button
SetSeeMoreButtonDisplay($w);
HideLoadingGif($w);
});
}
I have searched the WixCode API and as far as I can tell no property exists to change or read the “Number of Items to Display” property of the data set.
I have also tried clearing the repeater that is attached to the Dataset but that doesn’t work either.
We’re still working on completing the API for working with datasets and repeaters. Hopefully that will be out soon. In the meantime, you can probably achieve what you’re trying to do if you forgo the dataset and populate the repeater using code.
I have this exact same problem. There are 600 names on my web page and a search that uses the dataset filter, so being able to reset the number of items shown on a dataset is necessary, otherwise the search is slowed down tremendously. I tried using $w(“#dynamicDataset”).setPageSize(5); but $w(“#dynamicDataset”).loadMore() seems to override that. Any advice would be great!
Is the API able to reset the repeater size? Ive tried to implement:
(“#dataset1”).setPageSize(6)
(" #dataset 1").setFilter( wixData.filter() ) -with- (" #dataset 1").setSort( wixData.sort() );
and (’ #repeater 1’).data=
But the repeater still tries to load in hundreds of things at once if the repeater is changed after .loadMore() is called
The closest solution I’ve found is using:
wixLocation.to(wixLocation.url)
to simply refresh the page, but due to code in my site tab, this ruins my sites functionality.
Note that this post is originally from 2018 and you are much better adding a new post rather than bumping up an old post and referring back to this old post in a link, otherwise the post could be closed.