I’ve got a repeater showing items from my dataset that has lazy loading implemented (i.e. scroll to the bottom of the page and the next batch of items show). There are a series of filters on the page that the user can apply. When a filter is triggered I’ve implemented code which I want to reset the page size and then apply the filter.
However my issue is two fold:
-
At present is that when you scroll down the page a few times you end up with 100 odd items on the page, apply a filter to those 100 items and it takes AN AGE to apply the filter and update the items displayed.
-
The set page size isn’t actually applying, the dataset still shows 100 odd items once filtered, rather than resetting in size
Is there any way to:
-
Firstly, make sure set page size actually applies to the dataset
-
And, apple the set page size first before applying the filter to speed up execution of the query
Page code is below, I’ve stripped out a bunch to only show relevant bits. Please help I’m so stuck!
// Apply the filter - Price Dropdown
export function apply_filter(event, $w) {
generalFilter()
$w("#anchor1").scrollTo()
}
// Various Queries
function queryItContains() {
$w("#Scraper").setFilter(wixData.filter()
.contains("auction_house", $w('#auctionHouseDropdown').value)
.contains("auctiondateshort1", $w('#auctionDateDropdown').value)
.contains("makeclean", $w('#makeDropdown').value)
.contains("model", $w('#modelDropdown').value)
.contains("name", $w('#searchBox').value)
.between("priceGbpNumber", parseFloat($w('#priceFromDropdown').value), parseFloat($w('#priceToDropdown').value))
)
}
function queryItContainsMake() {
$w("#Scraper").setFilter(wixData.filter()
.contains("auction_house", $w('#auctionHouseDropdown').value)
.contains("auctiondateshort1", $w('#auctionDateDropdown').value)
.eq("makeclean", $w('#makeDropdown').value)
.eq("model", $w('#modelDropdown').value)
.contains("name", $w('#searchBox').value)
.between("priceGbpNumber", parseFloat($w('#priceFromDropdown').value), parseFloat($w('#priceToDropdown').value))
)
function generalFilter() {
// SET PAGE SIZE*********
$w("#Scraper").setPageSize(21)
.then(() => {
console.log("Page size set to 21");
})
.catch((err) => {
let errMsg = err.message;
let errCode = err.code;
});
// SELECT RIGHT FILTER
if ($w('#modelDropdown').value === '' && $w('#makeDropdown').value === '') {
queryItContains()
} else {
queryItContainsMake()
console.log("4")
}
}
// Lazy loading
export function loadingStrip_viewportEnter(event) {
$w("#loadingGif").show();
$w("#Scraper").loadMore()
.then(() => {
$w("#loadingGif").hide();
}
)
}