Live gallery filtering inside a repeater

Hi everyone,

I have a gallery displaying book covers, connected to a books dataset. The gallery is inside a repeater connected to a list of countries, and shows only books from the corresponding country in each item.

I would like to use a button to show only the books listed as “owned”.
I’ve tried this code but it seems to work only when the gallery is not inside the repeater :

import wixData from 'wix-data';

export function ownedButton_click(event) {
    $w('#booksDataset').setFilter(wixData.filter()
        .eq("owned", true)
    )
}

Do you have any ideas?
Thanks in advance! :slight_smile:

Hello,

Try refreshing the dataset after you set the filter because the datasetis still using the old unfiltered data.

Refresh

Best,
Majd

Thanks for the idea, unfortunately it doesn’t work either :confused:
I’ve tried with this code:

export function ownedButton_click(event) {
    $w('#booksDataset')
        .setFilter(wixData.filter().eq("owned", true))
        .then( () => {console.log("Done filtering booksDS");} )
        .then( () => {$w('#countriesDataset').refresh()
            .then( () => {console.log("Done refreshing countriesDS");} );
        } )
}

I’ve also tried to refresh the the #booksDataset instead of the #countriesDataset (I wasn’t sure which one you were talking about) but nothing happens.

I think I need to repopulate the repeater once the dataset is filtered but I don’t understand how to do that…