Sorting Repeating Group with Exisiting Filters

Hi
I’ve so far had a lot of help from community members on search result issues concerning filtering.

I am now turning to community members again for help in sorting the results.

Firstly, I have a hotel listing site that allows the user to filter the results based on a variety of parameters including property type, overall rating, facilities and neighborhood. These all function properly.

Now when I sort the results I am able to sort them as I intended to. I have accomplished this in a few different ways (I’ve tried three different ways to find a solution to the issue I am having.)

The main issue now is that when a user selects a parameter to sort by (lowest price for example) the repeating group search results are unable to be altered again by selecting any of the parameters to filter by (property type or neighborhood for example).

The other issue is that once a user clicks the button associated with the parameter that the search results are currently sorted by (the idea is to remove the sort) the search results stay “stuck” in the sorted order.

One thing to note is that I am able to successfully change the parameter to sort by after one has already been selected. For example, if I selected to sort by lowest price and then decide to sort by highest review score the search results do change their sort order correctly.

I have tried setting a conditional on the search results repeating group and got a strange error message. The conditional was successfully set (ie: no red lettering) but I did get an issue warning.

Also when testing this I got another error message after an excruciating long and failed progress attempt.

After this failed approach I decided to try setting the conditional to the following (see second condition)

This makes it so that the repeating group search results are empty when I select the button for sorting by the lowest price parameter.

So, the best I can get is as I currently have it set up in a workflow as seen below.

But again the issue remains that once a user has selected a parameter to sort by they are no longer able to remove the sort and are no longer able to select any parameters to filter by.

I am hoping to make the user experience as flawless as possible, which for me means they would be able to select some parameters to filter by (such as neighborhood), then sort by a parameter (such as lowest price) and then after that be able to select more parameters to filter by (such as property type or facilities) and then even be able to remove the sort parameter.

I have also made a copy of the app accessible and editable by all if anybody would like to have a crack at this.

https://bubble.io/page?name=index&id=hotel-listings-editable&tab=tabs-1

@NigelG @romanmg @dan1 @mente12 @luke2 @levon @sridharan.s @vincent56 @philnauta @emmanuel

2 Likes

Hi Again.

I was recently made aware that I didn’t provide enough information to make it possible for the community to try to assist as I didn’t provide details on how to re-create the issues I am facing. Below is a guide to re-create the issue so others would know exactly what I am having trouble with.

  1. On the index page a user would need to perform a search. At the moment my database is limited to about 5 different hotels. All are listed in Bangkok.

On the index page a user must first select hotels, then enter the location (Bangkok), arrival and departure dates as well as number of guests before they could press the search button.

  1. Once the user is taken to the “hotel_search” page there is a repeating group displaying all hotels that has the City Data Field as Bangkok under the Data Type of Hotel Listings.

On this page there are a few different sets of search filters to choose from. One set are the property types.

In the database each Hotel Listing has a data field of property type with only one possible type. When a user is using this parameter to filter the search results in the repeating group the user is able to select multiple property types to return results for all Hotel Listings that have the data field of a property type selected by the user.

  1. The user can also select a property facility of which a property may have a list of facilities. In the database I have each Hotel Listing containing a Data Field of facilities as a list. Also in the database is a Data Type of Facilities with a Data Field of Category as well as a Data Type of Property Facility Categories. (FYI in my updated version I have since added a Data Field as a list of Facilities in the Data Type of Property Facility Categories - not present in version of the app linked on this post) There are 16 categories and over 200 facilities.

When a user selects multiple facilities, only the properties that have all the facilities selected will be displayed in the repeating group.

  1. A user can also select a neighborhood as a filter, a overall rating as a filter as well as a location rating as a filter. When a user selects any of those options all properties that match the criteria will be displayed so long as they also meet the criteria set for property type and facilities selected.

All of the filter parameters are working as desired and I have no issues with those. Thanks to the help of @NigelG, @dan1 and other community members forum posts, tutorials and direct assistance.

The PROBLEM:

Once a user has selected all the parameters they wish to use as filters and they would like to sort the results in the repeating group by various parameters and they select one of the sort parameters:

The search results will sort and display the results correctly as intended. And when a user selects a different sort parameter the results are sorted again correctly.

HOWEVER, when a user has already selected a sort parameter, they can no longer select new or deselect existing filter parameters (ie: property type, neighborhood, facilities, overall rating or location rating.)

In terms of my logic and set up I have done the following things on page and in the workflow.

On the page (hotel_search) there are various custom states. One of which is sort feature as a text item.

In the workflow I have the custom state being set when a sort parameter is clicked.

The above custom state set on the button element of the sort parameter on the page is:

Then I have the search results repeating group data displayed set in the workflow:

Also in the workflow I have actions for when the sort parameter button is clicked on page and the parameter is already the value listed on the hotel_search page’s custom state

SO, my basic logic was to use a workflow to set the display of the repeating group search results to sort by the hotel_search’s sort feature’s value ( equal to the value of the button selected as a sort feature ).

I am not sure exactly where my logic has failed, but my goal is to allow a user to select any filter parameters and sort parameters in any order ( can’t predict user behavior ) and have the results displayed accordingly.

Hopefully this post will help others recreate the issue I am facing and somebody has the magic remedy I’m searching for.

Cheers and thanks to all those taking the time to lend a helping hand.

1 Like

I’m not sure about this, but I suspect that, when a user has selected a search other than default, and the “choose property type” selector is changed, you may need to do a fresh “display data in Repeating Group”.

I notice that this is how your sort works, but when options for “choose property type” are toggled, various custom states are set, but altered data is not sent to the repeating group.

You can observe that in the debugger in step-by-step mode. For example, load this search:

https://hotel-listings-editable.bubbleapps.io/version-test/hotel_search?debug_mode=true&city=Bangkok&arrival=Nov%209%2C%202018%2012%3A00%20am&departure=Nov%2019%2C%202018%2012%3A00%20am&guests=2%20Guests

This search displays 4 properties (2 hostels and 2 condos).

Select Hostel as prop type. You get 2 hostels in your search results. Now add Condo. You get a total of 4 properties in your search results.

NOW, turn on step-by-step and click a search constraint button like “stars”. At the end of that workflow, you do THIS (display list):

At that point, your list in the RG is now “fixed”.

If you now go and try to unclick Condo in the prop type selector, the workflow does some updating of custom states, but does not re-send data to the RG (so that the “condo” type properties would be removed):

I’m pretty sure you just need to force the RG to display the updated data. The way you’ve implemented this (which may or may not be quite the “right” or “best” way, I’m not sure), it does look to me like what is happening is the following:

  1. Page loads with all props that match displayed in the RG
  2. Choosing prop types adds or subtracts (using :plus item / :minus item) to a list in a custom state.
  3. The RG (when it contains the ORIGINAL list, responds appropriately).
  4. However, when user clicks a SORT option, you send a NEW list (it’s like a copy of the original list) to the RG to display the sorted values.
  5. In essence, this “breaks” the connection between the sorted list and the original list.
  6. If user then goes and selects property type options, you’re modifying custom states that are no longer associated with the list that’s actually displayed in the RG.

I may not have this exactly right, but that’s sort of what’s going on. Basically, I think you need to refresh your list (and restore sort order) when left hand options are toggled.

Again, seems like there’s probably a way to do this that doesn’t swap your RG’s source list as seems to be happening. (But perhaps not: As you mentioned in your first post, one’s impulse is to put a condition on the RG that results in a circular reference and so it’s not allowed.)

Anyway, i’m pretty sure what’s going on here is your search options and your prop type, etc. (left hand options) are essentially operating on different lists (after such time as the user clicks a sort option).

So that’s the diagnosis. Potential cure is send the correct data to the RG when left hand options change.

@keith

Thanks for taking the time to take a look at it. Your diagnosis makes perfect sense.

I’ve been playing around with workflows to reset data in repeating groups for a different part of the app the last two days. I believe I could put together a recurring workflow ( I believe a custom event ) so that each time a filter item is changed the repeating groups data is reset.

I think I will need to figure a way to keep the data sorted in the same order when the data in repeating group gets reset off a new filter parameter change.

I’m gonna play around with this tomorrow. Will update what I encounter - hopefully I will have screen shots of how I successfully tweak it.

Cheers

I got it to work finally.

Here is a link to a forum post outlining the steps.