I need to make Selection Tags search only one category and join what Input 1 contains as a value,
I managed to make them work separately but I need to join.
does anyone have an idea how i can do this?
export function input1_keyPress(event) { // seach
let alinhamento;
if (alinhamento) {
clearTimeout(alinhamento);
alinhamento = undefined;
}
alinhamento = setTimeout(() => {
filtro($w("#input1").value);
console.log($w("#input1").value)
$w("#textseach").text = $w("#input1").value; // show total results on a text
}, 500);
}
let ultimaPesquisa;
function filtro(pesquisa) {
if (ultimaPesquisa !== pesquisa) {
$w('#dataset1').setFilter(wixdata.filter() // set filter
.contains("nomeAba", $w("#input1").value)
.eq("visivel", true));
ultimaPesquisa = pesquisa;
//
var prevSelectedValue = null;
$w.onReady(function () {
let tags = $w('#caixaralho');
if (tags.value.length === 1) {
prevSelectedValue = tags.value[0];
} else if (tags.value.length > 1) {
tags.value = [];
}
if (!pesquisa.target.value || pesquisa.target.value.length === 0) {
pesquisa.target.value = [prevSelectedValue];
} else {
pesquisa.target.value = pesquisa.target.value.filter(x => x !== prevSelectedValue);
prevSelectedValue = pesquisa.target.value[0];
$w('#dataset1').setFilter(wixdata.filter() // set filter
.eq("filtrosloja", $w("#caixaralho").value)
.eq("visivel", true));
function createFilterThatMatchesAnyKeyword(selectedKeywords) {
return (selectedKeywords && selectedKeywords.length > 0) ?
// Filter content that fits any of the the selected keywords.
wixdata.filter().hasSome('filtrosloja', selectedKeywords) :
// When no keywords are selected, do not filter any content.
wixdata.filter();
}
let selectedKeywords = pesquisa.target.value;
let filter = createFilterThatMatchesAnyKeyword(selectedKeywords);
$w('#dataset1').setFilter(filter);
}
})
}
}
here is the complete code of one of the page
I know there must be complete chaos and it could be much less
but I'm happy with what I did
even if it's not the best way
I accept help
Waht if you would use the reset in the ELSE-part?
if(results.items.length > 0) { //...bla bla bla... else {$w('#repeater1').data = []}
Or perhaps changing your FILTER-OPTIONS ?
From contains ---> to eq ? or has Some ?
Try it out.
Hello petriell0 Anima,
i think you will have to connect your repeater programmatically by corvid to achieve your aim. You are using two differerent search/filtering-functions, which do not communicate/work together.
You should first collect the results in an ARRAY(object) for example, and then pulling these collected results into the repeater.
Something in this direction, where you can for example input a second filter.
Something like that.
import wixData from 'wix-data'; $w.onReady(function () {load_Data()}); export function BTNsearch_click(event) {load_Data()} function load_Data (parameter) {console.log("GO") wixData.query("Companies") .contains("column1", $w('#dropdown1').value) //inputting a second filter here .contains("column2", $w('#dropdown2').value) .find() .then( (results) => { if(results.items.length > 0) { let firstItem = results.items[0]; console.log(results.items) $w('#repeater1').data = results.items $w("#repeater1").onItemReady( ($item, itemData, index) => { $item("#pic").src = itemData.logo; $item("#ID").text = itemData.title; $item("#group").text = itemData.companyGroup; $item("#title").text = itemData.companyName; // $item("#image1").onClick( (event) => {} ); }); } else { } }) .catch( (err) => { let errorMsg = err; }); }