Hello there!
I have a repeater which is filtered using dropdown menus, a checkbox group (checkboxGroup1) and selection tags (benefitsT).
The dropdown menu filtering works fine. The problem lies within the checkbox group filtering and the selection tags (both fields in the database associated to these 2 are Tags and not Text fields).In the code I am using "hasSome" for these 2 filtering options in order to enable the visitor to select two or more options from the checkbox group (and filter the repeater upon a button click even if this is the only filter option selected) as well as select one or more of the selection tags and then filter all together.
In other words, the pain problem is that the checkboxGroup which is meant to filter database column "remote" does not work on it's own, but only if combined with the tags. What happens is, when you try to filter the repeater using only the checkboxes, the repeater shows no items as if it's empty - I'm assuming because if only a checkbox is selected and no other filtering options it thinks the value is null? There seems to be a problem if I use two "hasSome" filter lines, since changing one enables the other and vise versa, but they dont work when both lines contain "hasSome" for some reason - please help!
Here's that part of my code that is associated to the search button and the search function which filters the repeater: (problem area highlighted in red)
export function searchButton_click(event) {
search();
}
function search() { let selectedTags = $w("#benefitsT").value; let selectedTags2 = $w("#checkboxGroup1").value; wixData.query("jobpostings") .contains("field", String($w("#countryDropdown").value)) //.and(wixData.query("jobpostings").contains("location", String($w("#companyType").value))) .and(wixData.query("jobpostings").contains("type", String($w("#employment").value))) // .and(wixData.query("jobpostings").contains("remote", String($w("#checkboxGroup1").value))) .and(wixData.query("jobpostings").contains("companyType", String($w("#companySize").value))) .and(wixData.query("jobpostings").hasSome("benefits2", selectedTags)) .and(wixData.query("jobpostings").hasSome("remote", selectedTags2)) .find() .then(results => { $w("#repeater4").data = results.items; }); } Thank you! :(
Follow this link/post. You will find other posts related to the shown interaktive example. In one of the many related and connected posts, you will find your answer. You have just to read all of them.
Anybody? Please?