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

mvp_badge
MVP
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

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)?

mvp_badge
MVP

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

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

mvp_badge
MVP

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.

Hi Manish, 

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

mvp_badge
MVP
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

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)?

mvp_badge
MVP

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

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

Where it says "Set the value of each button item to Entities.Status.Label"

Does that mean to literally enter "Entities.Status.Label" as the value of each button or is there a value that I need to use instead of the word 'Label'?

Depending on the static identifier you are using, on the button group items it will show the records, for example:

If the static as 3 records, top1,top2,top3 on the button group item, the value that is going to be visible is one of these records to select, based on the variable on the button group that has the identifier of the static

Thanks, Marcio,

I'm not sure, but I think I am having trouble understanding your English as well as the Outsystems syntax.

You wrote "If the static as 3 records, top1,top2,top3 on the button group item, the value that is going to be visible is one of these records to select, based on the variable on the button group that has the identifier of the static"

Does that mean...

If the static as 3 records, top1,top2,top3 in the button group item. 

Does that mean that each button is considered to be a record in the button group? So when you say "On the button group item" that means "3 buttons in the button group" or are you referring to the button group as a single item?

You wrote "the value that is going to be visible is one of these records to select"

Does that mean...

When I click one of the buttons the records that are returned correspond to the static value of the button?

or 

When I select (click) one of the buttons the value shown corresponds to the static value of the button group?

Is the identifier the static value in the variable or the value assigned to the button?

I'm sorry to say that this is not becoming any clearer to me. It would be helpful if someone could spell out what happens when you click on a button, for example:

When you click on a button the static value assigned to the button is used by the action to compare the value of each record in the designated column of Entity and return the results.

If the above is true, then is the value of the column stored in a variable in the Action?

Thanks!

Paul







In the oml that I shared on your post, you can check and try to understand by seeing this image.

Hi Marcio, Thanks so much for trying to help me learn this.

I think I am starting to understand

Just to be clear, you are saying: When I click one of the buttons, the value assigned to the button will be saved in the buttongroup GenderValue variable?

I have been studying the thread started by Phillip, titled "Use Button Group to Filter by a List Attribute" in the hope that it will make more sense to me. I am still confused about whether there are reserved phrases like "StatusID" or whether those are ok to use or change.

Paul

No problem!

yes - "Just to be clear, you are saying: When I click one of the buttons, the value assigned to the buttonGroup will be saved in the button group GenderValue variable?"

When you have some words finish with the ID is because there is something related to an attribute of type ID of some entity.

Hi Marcio,

I'm guessing that you will get a better idea of where I am stuck if you look at my OML. How can I save my OML to share in the forums, but NOT share the private records in the entity at the same time? I could not find any way to dump the records or select all and delete. What do you suggest?

Paul



Send me a private message, and then we continue on the topic/thread/question you created

I don't want spam this thread, pls :)

Regards,

Márcio Carvalho

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.