Sort on filtered results in repeater

I am using filters for my vacation rental site and it works great:

export function search_onClick(event, $w) {
wixData.query(‘Properties’)
.contains(‘subLocation’,$w(’ #location ‘).value)
.contains(‘type’, $w(’ #Type ‘).value)
.ge(“guests”, Number($w(" #Guests “).value))
.ge(“bedrooms”, Number($w(” #Rooms “).value))
.ge(“bathrooms”, Number($w(” #Bathrooms ").value))
.find()
.then(res => {
$w(’ #repeater2 ‘).data = res.items;
$w(" #button6 ").show();
if (res.items.length === 0){$w(’ #box3 ‘).show();}
else $w(’ #box3 ').hide();
});
}

What I would like to do is have a sort by price descending & ascending.
This code works perfectly:

export function dropdown1_change(event, $w) {
if ($w(’ #dropdown1 ‘).value === ‘high’)
$w(" #dataset1 ").setSort(
wixData.sort()
.descending(“price”));
if
($w(’ #dropdown1 ‘).value=== ‘low’)
$w(" #dataset1 ").setSort(
wixData.sort()
.ascending(“price”));
if
($w(’ #dropdown1 ').value=== ‘none’)
$w(" #dataset1 ").setSort(
wixData.sort()
);
}

However, it works only on the unfiltered data . I would like users to be able to sort before they do any filtering (which is how it works now) but then also sort the filtered results in the repeater after they have refined their search with the above. Im guessing it would be similar to the res.items but not sure…

Can you please let me know how I would go about that? Thank you!!

3 Likes

Can anyone help please? @Yisrael, @Sam, @Roi, @Tal

Has this been solved yet?