Hello, I created a page with filter functionality with 5 dropdowns
3 with string values
2 with numeric values to find a product between 2 price range
4 filter seems to work fine together
3 string filters with 1 numeric filter works, either with min filter or with max filter
But when the 5th one is connected it doesn;t works
This is the search code
//SEARCH FUNCTION
function search ( ) {
$w ( "#dynamicDataset" ). onReady ( **function** () {
$w ( "#dynamicDataset" ). setFilter ( wixData . filter ()
. contains ( 'designer' , String ( $w ( '#dropdown1' ). value ))
. and ( wixData . filter (). contains ( "class" , String ( $w ( '#classFilter' ). value )))
. and ( wixData . filter (). contains ( "lengthM" , String ( $w ( '#lengthFilter' ). value )))
. and ( wixData . filter () . ge ( "price" , Number ( $w ( '#minPrice' ). value )))
)
. then ()
})
}
J.D
January 7, 2023, 7:29pm
2
I don’t see the .le() in your code
Apologies this is the full code along with on change functions on dropdown
//SEARCH FUNCTION
function search() {
$w("#dynamicDataset").onReady(function () {
$w("#dynamicDataset").setFilter(wixData.filter()
.contains('designer', String($w('#dropdown1').value))
.and(wixData.filter().contains("class", String($w('#classFilter').value)))
.and(wixData.filter().contains("lengthM", String($w('#lengthFilter').value)))
.and(wixData.filter() .ge("price", Number($w('#minPrice').value)))
.and(wixData.filter() .le("price", Number($w('#maxPrice').value)))
)
.then()
})
}
export function dropdown1_change(event) {
search();
$w(‘#reset1 ’).expand();
}
export function minPrice_change(event) {
search();
$w(‘#reset4 ’).expand();
}
export function maxPrice_change(event) {
search();
$w('#reset5').expand();
}
export function classFilter_change(event) {
search();
$w(‘#reset2 ’).expand();
}
export function lengthFilter_change(event) {
search();
$w('#reset3').expand();
}
Hello i have shared the full code above
Basically the .ge and .le functions are not working together on a filter even though technically the code is correct
J.D
January 8, 2023, 1:43pm
5
It should work. Anyway I’d do it without the .and() and String() (it’s simpler):
.contains(‘designer’, String($w(‘#dropdown1 ’).value))
wixData.filter()
.eq("class", $w("#classFilter").value)
.eq("lengthM", $w("#lengthFilter").value)
.ge("price", Number($w("#minPrice").value))
.le("price", Number($w("#maxPrice").value))
Thanks, but I implemented the code it doesn’t works
if i use the
.contains(‘designer’, String($w(‘#dropdown1 ’).value))
With
. eq ( “class” , $w ( “#classFilter ” ). value )
the repeater doesn’t gives any search values
Basically .ge is not working when chained with .le
I tried the . between function too that also doesn’t works
.and(wixData.filter().between(“price”, Number($w(‘#minPrice ’).value), Number($w(‘#maxPrice ’).value)))
export function minPrice_change(event) {
search();
$w(‘#reset4 ’).expand();
}
export function maxPrice_change(event) {
search();
$w(‘#reset5 ’).expand();
}
But the repeater doesn’t gives any value
J.D
January 9, 2023, 1:05pm
9
Maybe there’s no value that meets the conditions.
Otherwise, I have no idea.
I had a doubt so used text box with numeric input, also the database column is set to numeric.
Though it haven’t worked
the dropdown also have numbers, since its working when only used .ge, as soon as I use .le with it the filter doesn’t filter any value
Checked what data was it filtering
Since the filters were filtering it based on value it already has
So, may be we can add the highest dropdown value default for the max filter
But I am not sure how to set the max filter default using the code