Hello, I was trying to make a filter with dropdowns. The main idea is after select dropdown with the selector’s necessaries, filter database, and have the result. I have 3 filters, but 2 are working because they are union and use contains form but the other is an if and when I use deactivates the other filters even if it is in the first position or in last.
My questions are how can we do to use this 3 filter together using first the contains and then if conditional.
The format of values that of third filter is a boolean type. Filter that starts working and makes the other stop working is if statement
can you help me please to make 3 filters works simultaneously, alone or together using the button
thanks!!
//search button of clicking
export function searchButton_onClick(event, Sw) {
let searchIndustry = $w('#dropdown1').value;
let searchRegion= $w('#region').value;
let searchOds= $w('#sdg').value;
let filestore = $w('#sdg').value;
$w('#dataset1').setFilter(wixData.filter().contains("sector", searchIndustry).contains("region", searchRegion)).contains("ods", searchOds)
$w('#dataset1').onReady( () => {
if (filestore === '1') {
$w('#dataset1').setFilter(wixData.filter().eq('ods1', true));
}
if (filestore === '2') {
$w('#dataset1').setFilter(wixData.filter().eq('ods2', true));
}
if (filestore === '3') {
$w('#dataset1').setFilter(wixData.filter().eq('ods3', true));
}
if (filestore === '4') {
$w('#dataset1').setFilter(wixData.filter().eq('ods4', true));
}
if (filestore === '5') {
$w('#dataset1').setFilter(wixData.filter().eq('ods5', true));
}
if (filestore === '6') {
$w('#dataset1').setFilter(wixData.filter().eq('ods6', true));
}
if (filestore === '7') {
$w('#dataset1').setFilter(wixData.filter().eq('ods7', true));
}
if (filestore === '8') {
$w('#dataset1').setFilter(wixData.filter().eq('ods8', true));
}
if (filestore === '9') {
$w('#dataset1').setFilter(wixData.filter().eq('ods9', true));
}
if (filestore === '10') {
$w('#dataset1').setFilter(wixData.filter().eq('ods10', true));
}
if (filestore === '11') {
$w('#dataset1').setFilter(wixData.filter().eq('ods11', true));
}
if (filestore === '12') {
$w('#dataset1').setFilter(wixData.filter().eq('ods12', true));
}
if (filestore === '13') {
$w('#dataset1').setFilter(wixData.filter().eq('ods13', true));
}
if (filestore === '14') {
$w('#dataset1').setFilter(wixData.filter().eq('ods14', true));
}
if (filestore === '15') {
$w('#dataset1').setFilter(wixData.filter().eq('ods15', true));
}
if (filestore === '16') {
$w('#dataset1').setFilter(wixData.filter().eq('ods16', true));
}
if (filestore === '17') {
$w('#dataset1').setFilter(wixData.filter().eq('ods17', true));
}
}
)
.then((results) => {
console.log("Dataset is now filtered");
//$w('#repeater1').data = results.items;
resultsChecker();
});
//$w('#repeater1').expand();
$w("#dropdown1").value = "Select Type:";
$w("#region").value = "Select Category:";
}
// resultsChecker function displays a message if no results are returned
function resultsChecker(event){
$w("#dataset1").onReady( () => {
let count = $w("#dataset1").getTotalCount();
// if repeater has results, show them
if(count > 0){
$w("#text108").hide(); $w("#text108").collapse();
$w("#repeater1").expand(); $w("#repeater1").show();
}
// if repeater returns no results, then show message
if(count === 0){
$w("#text108").show(); $w("#text108").expand();
$w("#repeater1").collapse(); $w("#repeater1").hide();
}
});
}