Hi everyone:
I’ve been struggling with the filters for a while now and our deadline is just around the corner.
I would need your advice on this.
What I am trying to do:
I would like to add refine search + a group checkbox search + search by wording search for one dataset. Also, I’m looking to include reset values to display all. (nevermind it reads twice Provincia, the values are different).
So the first issue:
I’ve emulated the code from:
Whats happening:
Not working.
Questions:
MAybe its because I’ve missed something that I should have changed from the previous article.
Yeap. newbie
-What would the “originalPropertiesInfo” stand for?
- " export function Guests_change(event)" - should this stand for the dropdown?
- The “Buscar btn” isn’t refining - I guess it’s because I’ve got these wrong.
- How can I include the groupcheckbox into this equation?
- How about word search? (magnifying glass input field)?
Many thanks for your support!
import wixData from ‘wix-data’ ;
$w.onReady( function () {
let originalPropertiesInfo = ;
$w.onReady( function () {
//Query to get the information from the database
wixData.query( “passCo” )
.find()
.then((results) => {
originalPropertiesInfo = results.items;
$w( #listRepeater
).data = originalPropertiesInfo;
})
. catch ((err) => {
let errorMsg = err;
});
//Set the information to the repeater
$w( #listRepeater
).onItemReady(($w, itemData) => {
//add here all the relevant elements of the repeater
//In this case, I’ve added a text and an image to the repeater
$w( #iniciativa
).text = itemData.title;
$w( #TextAct
).text = itemData.actividad;
$w( ‘#logo’ ).src = itemData.logo;
$w( #description
).text = itemData.resumen;
$w( #Provincia
).text = itemData.provincia;
$w( #embajada
).text = itemData.embajada;
$w( #imgEmb
).src = itemData.embajadaimagen;
});
});
function filterResults() {
function filterResults(results){
const actividad = $w( ‘#iActividad’ ).value;
const provincia = $w( ‘#iProvincia’ ).value;
if (provincia && provincia !== ‘Elige Provincia’ ) {
results = results.filter(item => item.provincia >= provincia);
}
//after the first if statement, the results is filtered
if (actividad && actividad !== ‘Elige Actividad’ ) {
results = results.filter(item => item.actividad >= actividad);
}
//results is filtered by both guests and rooms
return results;
}
//filtering the results
export function Guests_change(event) {
//setting the data
$w( `#listRepeater` ).data = filteredResults;
$w( ‘#listRepeater’ ).data = filteredResults;
//setting the repeater elements
$w( ‘#listRepeater’ ).forEachItem(($w, itemData, index) => {
//setting the repeater elements
$w( `#listRepeater` ).onItemReady(($w, itemData) => {
console.log(itemData.title);
$w( `#iniciativa` ).text = itemData.title;
$w( `#TextAct` ).text = itemData.actividad;
$w( '#logo' ).src = itemData.logo;
$w( `#description` ).text = itemData.resumen;
$w( `#Provincia` ).text = itemData.provincia;
$w( `#embajada` ).text = itemData.embajada;
$w( `#imgEmb` ).src = itemData.embajadaimagen;
});
}
export function BuscarBtn_click(event, $w) {
//Add your code for this event here:
filterResults();
}