i am currently trying to add a search bar to my wix store, to filter out products. my question is can i filter the products that are displayed on the listgrid? can someone help me on this.
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Hi @Henry Chan
I hope this video can help you :
https://www.youtube.com/watch?v=Hx7_8-lRsW0&feature=youtu.be
This is the full code from the video :
import wixData from "wix-data"; $w.onReady(() => { loadContinents(); }); let lastFilterTitle; let lastFilterContinent; let debounceTimer; export function iTitle_keyPress(event, $w) { if (debounceTimer) { clearTimeout(debounceTimer); debounceTimer = undefined; } debounceTimer = setTimeout(() => { filter($w('#iTitle').value, lastFilterContinent); }, 500); } export function iContinent_change(event, $w) { filter(lastFilterTitle, $w('#iContinent').value); } function filter(title, continent) { if (lastFilterTitle !== title || lastFilterContinent !== continent) { let newFilter = wixData.filter(); if (title) newFilter = newFilter.contains('articleTitle', title); if (continent) newFilter = newFilter.contains('continent', continent); $w('#dataset1').setFilter(newFilter); lastFilterTitle = title; lastFilterContinent = continent; } } function loadContinents() { wixData.query('Continents') .find() .then(res => { let options = [{"value": '', "label": 'All Continents'}]; options.push(...res.items.map(continent => { return {"value": continent.title, "label": continent.title}; })); $w('#iContinent').options = options; }); }