Question:
How can I filter Events according to categories using selection tags (while showcasing results in a repeater connected to Events Dataset)?
Product:
Wix Studio Editor, Events
What are you trying to achieve:
I have a repeater and selection tags connected to Events Dataset, trying to allow users to filter the repeater according to Events Category.
What have you already tried:
I have tried many things - this is the code I am currently using, the Error that come back is that the collection doesnt exist on the page, which isnt true.
import wixData from ‘wix-data’;
$w.onReady(function () {
// Add an event handler for when the selection tag value changes
$w(“#selectionTags1”).onChange((event) => {
// Get the new value of the selection tag
const newValue = event.target.value;
// Filter the dataset based on the selected value
filterDataset(newValue);
});
});
// Function to filter the dataset based on the selected value
function filterDataset(selectedValue) {
// Filter the dataset based on the selected value
wixData.query(“events”)
.eq(“categories”, selectedValue) // Replace “columnName” with the name of your dataset column
.find()
.then((results) => {
// Set the filtered results to the dataset
$w(“#events”).setFilter(wixData.filter().eq(“categories”, selectedValue));
// Replace “columnName” with the name of your dataset column
})
.catch((error) => {
console.error(error);
});
}