Hi, i wrote this code for filter a dataset 2 times, first for the user and the second for the category of a product.
The category filtering work, but the user filter doesn't work ( the user is not logged in but I created a small list of users invented in a dataset, therefore the id is that of the row of the customer dataset)
How can I solve it?
import wixData from 'wix-data';
import wixUsers from 'wix-users';
let utente;
let categoria;
$w.onReady(function () {
let utilizzatore = wixUsers.currentUser.id;
console.log(utilizzatore)
});
function filtering (category, user) {
user = $w("#dbClienti").getCurrentItem();
console.log(user);
var newFilter = wixData.filter()
newFilter = newFilter.eq('categoria', category);
newFilter = newFilter.eq('cliente', user);
$w('#dbAcquisti').setFilter(newFilter);
console.log(newFilter)
utente = user
categoria = category
}
export function iptDropdown_change(event) {
let adjGenre;
if ($w('#iptDropdown').value !== 'tutti' ) {
adjGenre = $w('#iptDropdown').value;
}
filtering(adjGenre, utente);
}
Hello,
Please check related forum posts, this question was raised multiple times:
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-multiple-groups-filter
https://www.wix.com/corvid/forum/community-discussion/multiple-filters
https://www.wix.com/corvid/forum/community-discussion/filter-collection-by-multiple-fields
https://www.wix.com/corvid/forum/community-discussion/reverse-filter-multiple-filters-overlapping-filters
https://www.wix.com/corvid/forum/community-discussion/filter-dataset-with-2-filters
https://www.wix.com/corvid/forum/community-discussion/multiple-filters