-1

Good morning, I am learning how to work on wix for a school project and i have a database with 148 rows.

The database contains name(key), image, nickname and description. The database is being all loaded onto a single page through a repeater but 148 images in a single page makes it to slow to open.

How do i make to separate it just like when you search on google, you have page 1 2 3 4.... This has to work with a search bar.

The repeater alredy is connected to the database and the search bar code is the following:


import wixData from "wix-data";

let lastFilterTitle;
let debounceTimer;
export function input1_keyPress(event, $w) {
    if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w('#input1').value, lastFilterTitle);
    }, 200);
}

function filter(title) {
    if (lastFilterTitle !== title) {
        let newFilter = wixData.filter();
        if (title)
            newFilter = newFilter.contains('title', title);
        $w('#dataset1').setFilter(newFilter);
        lastFilterTitle = title;
    }
}

Dimitri Putin
  • 29
  • 1
  • 7

1 Answers1

2

When you create a dataset attached to the repeater, the dataset is already paginated as long as you limit the page size in the dataset settings. If you attach a pagination bar (Ad > Interactive > Pagination Bar), and bind it to your same dataset, it will automatically create pagination for your dataset.

When using search, you should use the setFilter function on the dataset, not wixData, to make sure you don't lose the paging.