Challenge: Filter items and only show them and the groups that contain them
So I was building a searchable and runtime manageable FAQ page and during the development of the search functionality I started to think: "I can do this in many ways, but what is the most efficient one?". This FAQ and search has two layers: Items and item groups. Perhaps an OverviewHelper. When you search, you only want to show the items that match the search query and the sections corresponding with the items. One option is to use a second association between 'Section' and 'Item' that is set when the item matches the search query and have the page only show the 'associated' ones. Another way is to have each item stored as a persistable entity, but copy each item to non-persistent ones and, when searching, delete all NP's and recreate and show new copies of those that match the search query. I bet there are more options. As much as I enjoy reading the challenges on StackOverflow, perhaps one challenge here on MendixCloud as well to both 'show off' and share knowledge to other developers? The Challenge So: If you have a page containing items and item groups and you want to show only the items and their corresponding section when they match the search query, while hiding all the other items, how would you achieve that functionality? Show Microflows and perhaps a description. And... Go!
I would use a listen-to widget which listens to the selected FAQ Category and only show FAQ's from that selected category in the listen-to widget.
Let's post my own solution as a starter. A short description: When there is an actual search string (not empty or ''), over the already retrieved list of all sections will be iterated and each reference set will be emptied. Then a Xpath retrieve of Items that match the search query will be made and iterated over. In that loop, each corresponding section will be retrieved and each section will have an associated be -added- to the iterated over Item.
Had a completely different, much more bloat and complex microflow before this one. I don't think it can be much simpler :)