@jonatandor35 OK lets go by parts, first i wrote the code for searching the nombrerelato and worked fine.
import wixData from “wix-data”;
let debounceTimer;
export function Irelato_keyPress(event, $W) {
if (debounceTimer){
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#Irelato’).value);
},200);
}
let lastFilterNombrerelato;
function filter(Nombrerelato) {
if (lastFilterNombrerelato !== Nombrerelato) {
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘nombreDelRelato’, Nombrerelato));
lastFilterNombrerelato = Nombrerelato;
}
}
After this i modified the code to try to filter of the list (even if i don’t perform a nombre relato search)
wothi the dropdown1 that have 3 options Nacional, Internacional and todos that is the default state of the list.
this is the code
import wixData from “wix-data”
$w.onReady(() => {
loadCategoria();
});
let lastFilterNombrerelato;
let lastFilterCategoria
let debounceTimer;
export function Irelato_keyPress_1(event, $w) {
if (debounceTimer){
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
filter($w(‘#Irelato’).value,lastFilterNombrerelato);
}
export function dropdown1_change(event, $w) {
filter(lastFilterCategoria, $w(‘#dropdown1’).value);
}
function filter (nombrerelato, categoria){
if (lastFilterNombrerelato !== nombrerelato || lastFilterCategoria !== categoria) {
let newFilter = wixData.filter();
if (nombrerelato)
newFilter = newFilter.contains(‘nombreDelRelato’, nombrerelato);
if (categoria)
newFilter = newFilter.contains(‘categoria’, categoria)
$w(‘#dataset1’).setFilter(newFilter);
lastFilterNombrerelato = nombrerelato;
lastFilterCategoria = categoria;
}
}
function loadCategoria (){
wixData.query(‘ParticipantesConcurso’)
.find()
.then(res => {
let options = [{“value”: ‘’, “label”: ‘Todos’}];
options.push(…res.items.map(categoria => {
return {“value”: categoria.title, “label”: categoria.title};
}));
$w(‘#dropdown1’).options = options;
});
}
Running this code is not working i tried with the loadCategoria that you pass me but not working. have you any way to do a simpler selection combined with the search?