15
Views
6
Comments
Solved
Use Button Group to Filter by a List Attribute
Application Type
Traditional Web
Service Studio Version
11.10.8 (Build 37958)
Platform Version
11.11.0 (Build 26942)

Hello all,


I am having trouble using buttons to filter a list.

First my current status:

A list is created from entries in my database, which is displayed on the homepage. 

Above the list there is a button group, with which I always want to filter the list by certain criteria. The list contains many tasks with different statuses. Each button contains a status and when clicked, the list should display only the items that belong to it. 


So far, each button has been assigned the value entities.Status.Name (in Screenshot Open) and then I am faced with the problem of my question: how can the button filter the list?


First, is it correct to add a matching event to each button so that the filtering can be performed?

Next, I already have thought of an onclick event and unfortunately I don't know how to proceed so that access to the list or database entries is possible. Do I also need attributes with properties? 


I have attached screenshots from the home screen. The list is called getbestehendetasks and is not used anywhere else.  Please don't get confused, because everything is written in german. For solution approaches it is enough if I can filter first only on the status Open. Everything else works then the same. 

Since this is my first application with OutSystems for a school project, it would be very helpful if you could give as exact steps as possible. 


Thank you for your contributions and if you need more screenshots or info, I'll be happy to provide it! 


Thanks a lot!

homescreenANDbuttoninfo.pdf

Rank: #54
Solution

Hi Philip,


You need to:

1 - Create a screen variable of type Status Identifier, let's call it StatusId;
2 - Set the variable of the Button Group widget to be StatusId and define a screen action on the OnChange event:

 

3 - Set the value of each button item to Entities.Status.Label except the first one "Alle tasks" that you should set to NullIdentifier() (which would not be filtering)
4 - On your query GetBestehendeTasks, add a filter StatusId = NullIdentifier() or Status.Id = StatusId (this will make your tasks be filtered, except on the All Tasks option where no filter will be applied)
5 - Refresh your query on the screen action of the OnChange event you set on step 2.


And that's it, hope it helps.


Regards,
João

Rank: #55713

Hi João,

Thank you for the detailed instructions! With the basic understanding and your instructions, I will be able to solve this. 

I still have a small ambiguity to step 4: should I decide for the filter option for StatusId = NullIdentifier() or for the other option Status.Id = StatusId or did you mean that I include this as a whole expression with the `or´ (highlighted in bold in your solution)?

Rank: #54

Hi Philip,


The status entity should contain the status your task can have and "All tasks" is not a status a task can have, therefore I would definitely not have the All Tasks as a StatusId but instead as the NullIdentifier() representing no filter is applied.


Feel free to mark a solution the answer / answers that helped you solved your problem so other developers with the same question can find the help they need.


Kind regards,
João

Rank: #55713

Okay, perfect! Thanks for your constructive support and thanks again

Rank: #148

Hi Philip,

You can have a local variable with the type of status and you can use it as a filter in your query which is bind with your table and on click of your button you can change the value of your local variable with the same status clicked by the button and refresh the query.

Rank: #55713

Hi Manish, 

thanks for your approach and it is very helpful to me for solution of my problem! 

Rank: #54
Solution

Hi Philip,


You need to:

1 - Create a screen variable of type Status Identifier, let's call it StatusId;
2 - Set the variable of the Button Group widget to be StatusId and define a screen action on the OnChange event:

 

3 - Set the value of each button item to Entities.Status.Label except the first one "Alle tasks" that you should set to NullIdentifier() (which would not be filtering)
4 - On your query GetBestehendeTasks, add a filter StatusId = NullIdentifier() or Status.Id = StatusId (this will make your tasks be filtered, except on the All Tasks option where no filter will be applied)
5 - Refresh your query on the screen action of the OnChange event you set on step 2.


And that's it, hope it helps.


Regards,
João

Rank: #55713

Hi João,

Thank you for the detailed instructions! With the basic understanding and your instructions, I will be able to solve this. 

I still have a small ambiguity to step 4: should I decide for the filter option for StatusId = NullIdentifier() or for the other option Status.Id = StatusId or did you mean that I include this as a whole expression with the `or´ (highlighted in bold in your solution)?

Rank: #54

Hi Philip,


The status entity should contain the status your task can have and "All tasks" is not a status a task can have, therefore I would definitely not have the All Tasks as a StatusId but instead as the NullIdentifier() representing no filter is applied.


Feel free to mark a solution the answer / answers that helped you solved your problem so other developers with the same question can find the help they need.


Kind regards,
João

Rank: #55713

Okay, perfect! Thanks for your constructive support and thanks again