Button to change search results

Button to change search results

  

I have a main screen to display List Records. It displays all. I am adding "Category" buttons at the top. IF my category is "Pets" - then I want to click that button and display only those records with Category=Pets instead of clicking the default "Search" button. How do I achieve this?

Thanks,
Darrell
Hi Darrell,
As usual, this can be done in more than way. The option I suggest is making each of those buttons direct to a different action (almost empty action - just re-renders the page) - the only thing you make is an assign to a text variable (eg. "SearchCategory") different on each action. The button must have method submit.
In the aggregate you must have a filter similar to this: MyTable.Category like "%" + SearchCategory + "%".

Do you have many categories? This might not be the best approach for your use case, but you can understand how it works and maybe addapt to your needs.
Hi Tiago,

Thanks for the solution. I do have 16 categories. The buttons are color coded. Are you saying to have the button "Food" click to an empty action and in the aggregate inside the preparation of the screen to add  Classifieds2.Category like "%" + SearchFood + "%"  ? I have a Category entity and the Identifier in that entity is tied to the CategoryId entity in Classifieds2. I tried as you suggested but it's not a text field but an idenifier. If I add it to the screen prepartation then it always loads it with "food" and only entries with 'food' as the category show up. How would I modify your solution to not be a text search or is there a way to still do that? I can attach the project/module if you want to see it.

Thanks,
Darrell

Here's a quick update. I got it to work!

Added a (example) local variable "Search Food" to the Classifieds screen.
Created an action called "SearchFood"
I added an "Assign" to the action and assigned the SearchFood variable. Set the value to "Food"
On the preparation for the screen I added this to the filter: Category.Name like "%" + SearchFood + "%"

ONLY issue now is - when I add more than one. I have SearchFood working - but when I add SearchToys - it only shows the results of the first one I click on after the page loads. If I click on the Food button - it will display that - but if I then click the Toys button - it displays NOTHING. Any ideas?

Thanks for your help,
Darrell