for my website I added a filter through three dropdowns, two of them are conditional, it works almost perfectly. the problem is that when I select any of the options of any of the dropdowns the repeater disappears. then when I click on the search button, the repeater appears and works correctly, here I leave my code, maybe someone can help me...
import { local } from 'wix-storage';
import wixData from 'wix-data';
import { Land, Service, SpanienRegion, PortugalRegion, ItalienRegion } from 'public/Lander.js';
//Search function
export function search_click(event, $w) { //Button onClick event
$w("#dataset1").setFilter(wixData.filter() //Set dataset to filter
.contains("title", $w("#land").value) //location field key and dropdown
.contains("stadt", $w("#region").value) //Restaurant field key and dropdown
.contains("tags", $w("#service").value)) //Cuisine field key and dropdown
.then((results) => {
let count = $w('#dataset1').getTotalCount();
if (count === 0) {
$w('#noResultsText').show();
} else {
$w('#noResultsText').hide();
}
console.log("Dataset is filtered");
$w("#repeater_ID").data = results.items; //Repeater ID
})
.catch((err) => {
console.log(err)
});
let count = $w('#dataset1').getTotalCount()
console.log(count);
$w("#repeater2").expand; //Repeater expands after filter
}
//Conditional Dropdown
$w.onReady(function () {
$w('#land').options = Land;
$w('#land').placeholder = 'Land';
$w('#land').onChange(() => {
let location = $w("#land").value
$w("#dataset1").setFilter(wixData.filter()
.eq('stadt', location))
if($w('#land').value === 'Spanien') {
$w('#region').options = SpanienRegion;
$w('#region').placeholder = 'Regionen aus Spanien';
$w('#service').options = Service;
$w('#service').placeholder = 'Service Auswählen';
$w('#service').enable();
$w('#region').enable();
} else if ($w('#land').value === 'Portugal') {
$w('#region').options = PortugalRegion;
$w('#region').placeholder = 'Regionen aus Portugal';
$w('#service').options = Service;
$w('#service').placeholder = 'Service Auswählen';
$w('#service').enable();
$w('#region').enable();
} else if ($w('#land').value === 'Italien') {
$w('#region').options = ItalienRegion;
$w('#region').placeholder = 'Regionen aus Italien';
$w('#service').options = Service;
$w('#service').placeholder = 'Service Auswählen';
$w('#service').enable();
$w('#region').enable();
}
});
});
Perhaps you should describe your situation a little bit more and put some more light into the darkness of your project.
-How does look your database/database-structure?
-which data does hold your —> 'public/Lander.js
-perhaps you have also the one or another screenshot which you can show to visualize your situation a little bit better.
You know —> the more INPUT —> the more OUTPUT!
( German translation )
Was befindet sich denn auf der —> ‘public/Lander.js’ ??? Wie sieht deine ‘public/Lander.js’ aus?
Wie soll sich die Auswahl denn verhalten?
Soll die Suche beginnen sobald sich eines der Werte im Dropdown ändert?
Oder soll die suche Beginnen sobald man auf den Searchbutton clickt?
Wie sieht die Struktur deiner Datenbank aus? Du solltest schon etwas mehr Informationen hinsichtlich deines Projekts geben womit man arbeiten kann.
Je mehr INPUT, desto mehr OUTPUT!
Beschreib mal etwas akribischer deine Situation und welche Funktionen du genau erreichen möchtest.
Vielleicht sogar am besten noch ein oder paar Screenshots, damit man deine Situation auch etwas besser deuten und interpretieren kann.
Leider haben die meisten (oder besser gesagt —> KEINER) dein Project direkt vor Augen, deswegen ist eine genaue Beschreibung das A und O um eine gute Antwort zu erhalten.