Hi everybody, I'm not going to bore you with my life story and get straight to the point. What I'm looking to create are three dropdown's with three options for "type", "location" and "price". Which then populate "repeater1" with the results filtered from "dataset1" after choosing one or all of the options available and clicking on the "search" button. It would look something like this:
I have been working on this for a few weeks and tried so many different options and tutorials and nothing seems to work. The last one I followed was https://youtu.be/QhMKnm1f6EU because it's the closest to what I'm looking for yet when I press "search" NOTHING happens. Here's a link to what I'm working on https://www.mmcproperties.es/try4 and the code is below.
I really hope someone can help me with this before I lose my mind!
Best regards.
MB
import wixData from 'wix-data'; // For full API documentation, including code examples, visit http://wix.to/94BuAAs $w.onReady(function () { //TODO: write your page related code here... }); export function button_click(event, $w) { $w('#dataset1').setFilter(wixData.filter() .contains("type", $w('#dropdown1').value) .contains("location", $w('#dropdown2').value) .contains("price", $w('#dropdown3').value)) .then((results) => { console.log("Dataset is now filtered"); $w('#repeater1').data = results.items; }).catch((err)) = { console.log(err); }); $w('#repeater1').expand(); }
Hey MB,
Wow! I had a brain fart on this one. Completely missed that you can't use .contain for a number - and the price field is a number.
Try this:
export async function button_click(event, $w) { $w("#dataset1").setFilter(wixData.filter() .contains("type", $w('#dropdown1').value) .contains("location", $w('#dropdown2').value) .eq("price", Number($w('#dropdown3').value)) ) .then(() => { console.log("Dataset is now filtered"); }) .catch((err) => { console.log(err); }); $w('#repeater1').expand(); }