I am trying to set the filter on a dataset. The collection for the data set has a reference property called origin that represents an origin airport. It references my Airport collection. The Airport collection has a code field. I am trying to filter the dataset to only show data where the origin’s code is “SLC”. How can I accomplish this? I tried the following line of code but it isn’t working.
I think you should put the Airport dataset on the page as well (set it via the editor UI to only show 1 item).
Then:
//call it whenever you need (but only after both datasets are ready:
function filter(){
$w('#airportDataset').setFilter(wixData.filter().eq('code', 'SLC'))
.then(() => {
const originId = $w('#airportDataset').getCurrentItem()?.id;
$w('#mainDataset').setFilter(wixData.filter().eq('origin',originId))
})
}