I have a collection list with several advanced filters. I want to show text like ‘no results for the filters selected’. I know there isn’t a native solution in Weweb. I also know a backend solution or filtering at the collection level are options. However, with so many filters, I really prefer to just do it at this level.
I am trying to solve it with some JS and have used this code to get the html id of the collection list, and figure out how many children it has.
This has gotten me a little progress, but I am having 2 major problems:
First: when the collection list has no items, it still shows as having 1 child. So a filtered list with 0 and 1 both return 1 item. making it unable to distinguish when there are 0 items.
Second: the value updates in the javascript code, but the condition does NOT update as I filter the list. In other words, if I bind the display to if that JS code is less than 2. It won’t update despite the list being smaller than 2.
An API call or variable change on each filter would be way too laborious for me. I also really enjoyed the live filtering per each filter and don’t want to turn it into ‘choose all filters then apply’.
Again, I stated that I have ~10+ filters and a formula for all of them would be complicated to maintain and so I am looking to see if I can create a simpler method.
You can put your filters inside the formula so you can reuse the formula everywhere you need the filtered collection, it will be easier yo maintain and you will be able to build condition on top, using the formula Length for example.
This solution doesn’t work. applying the length() over the reusable formula that has the filters applied doesn’t pull the filtered length. It pulls the unfiltered length.
Oh yes, you’re right, we already have a bug opened on it. Should be fixed this week! If you want to follow the advancement of the ticket you can open one on support.weweb.io