Hello! I am in way over my head. I managed to code selection tags to filter the wanted items to show in repeater. However I am also using dropdown filters that connect to these items. How do I code it so that when a user selects something from the dropdown and then from the selection tags, the filter will still take into account the dropdown selection - and vice versa?
Here is my code now:
The first .onReady function is for the selection tags and the other one is for a button to reset the dropdown filters.
import wixData from 'wix-data';
const collectionName = 'Erikoiskontit';
const fieldToFilterByInCollection = 'varustelut';
$w.onReady(function () {
loadDataToRepeater();
$w('#selectionTags2').onChange((event) => {
const selectedTags = $w('#selectionTags2').value;
loadDataToRepeater(selectedTags);
})
});
function loadDataToRepeater(selectedCategories = []) {
let dataQuery = wixData.query(collectionName);
if (selectedCategories.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories);
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items;
$w('#propertiesRepeater').data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show();
} else {
$w('#noResultsFound').hide();
}
})
}
$w.onReady(function () {
// TODO: write your page related code here...
});
export function button21_click(event) {
$w('#dropdown1').value=undefined;
$w('#dropdown2').value=undefined;
$w('#dropdown4').value=undefined;
$w('#dropdown1').resetValidityIndication();
$w('#dropdown2').resetValidityIndication();
$w('#dropdown4').resetValidityIndication();
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
$w('#dataset2').refresh()// Add your code for this event here:
}