Requirement
Implementing Gallery data filtering using a radio button.
Details
Let’s say we have a requirement to filter gallery data based on the selection of the radio button like below
![Filtering Gallery using Radio Button]()
To implement the filter, I am using collection here and Dataverse Account entity as data source where I have records of different types (using the Relationship Type attribute for customer category). So first let’s create two collections, one which will hold active accounts and another one where we will store filtered accounts based on the radio selection.
![Filtering Gallery using Radio Button]()
Now let’s place a radio button and change its Layout property to Horizontal and set the Items property like below
![Filtering Gallery using Radio Button]()
Now let’s place a gallery control and set our second collection under the Items property
![Filtering Gallery using Radio Button]()
By default, you won’t see any data in the gallery control. To load data initially we can run OnStart manually like below
![Filtering Gallery using Radio Button]()
Now let’s place below expression Onselect property of radio control
If(
currentfilter.Selected.Value = 1,
ClearCollect(
currentCollects,
Filter(
ActiveAccountsCols,
'Relationship Type' = 'Relationship Type (Accounts)'.Customer
)
),
currentfilter.Selected.Value = 2,
ClearCollect(
currentCollects,
Filter(
ActiveAccountsCols,
'Relationship Type' = 'Relationship Type (Accounts)'.Investor
)
),
currentfilter.Selected.Value = 3,
ClearCollect(
currentCollects,
Filter(
ActiveAccountsCols,
'Relationship Type' = 'Relationship Type (Accounts)'.Partner
)
)
)
Finally, let’s setup "Customer" under the Default property
Now play your app filtering should work fine.
Summary
This is how we can filter gallery control.
Hope it will help someone !!
Keep learning and Keep Sharing !!