i’m trying to create a page which searches my database and filters it with a dropdown, and then displays the results on a table. I have a very basic understanding with code and just need a little guiding. the search bar works as intended and i think the code for the dropdown is also good but i think the problem is the dropdown for some reason is having trouble taking the information from my database and putting it into the list, when i load it in the preview the only thing in the dropdown list is “All Categories” which is an option i created in the code. this is the warning i get.
Here is my code.
LEGEND
dropdown = #iCategory
searchInput = #iTitle
database = ProductsALL
dataset = #dataset1
database field ID for dropdown = category
import wixData from “wix-data”;
$w.onReady(() => {
wixData.query(‘ProductsALL’)
.find()
.then(res => {
let options = [{“value”: ‘’, ‘label’: ‘All Categories’}];
options.push(…res.items.map(category => {
return {‘value’ : category.title, ‘label’: category.title}
}));
$w(‘#iCategory’).options = options;
})
});
let lastFilterTitle;
let lastFilterCategory;
let debounceTimer
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#iTitle’).value, lastFilterCategory);
}, 200);
}
function filter(title, category) {
if (lastFilterTitle !== title || lastFilterCategory !== category) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘model’, title);
if (category)
newFilter = newFilter.eq(‘category’, category);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterCategory = category;
}
}
export function iCategory_change(event, $w) {
filter(lastFilterTitle, $w(‘#iCategory’).value);
}
Please help with this a soon as you can thankyou.
Fynn.