I have a gallery that's populated with a collection from a SQL Data Source
I want to be able to filter the gallery based on whichever radio button I select.
Currently I have the checkboxes set up like this:
OnCheck: Collect(checkedRow,ThisItem)
OnUncheck: Collect(uncheckedRow,ThisItem)
But this solution only creates a collection for the OnCheck (Makes sense since I don't uncheck some rows so those lines won't be saved in the uncheckedRow collection)
How can I set up the gallery to show only the checked and unchecked rows based on the radio button selected.
Also, how to I set the uncheckRow collection to populate all the unchecked rows?
@jrletner Thank you. It makes a lot of sense. I've managed to get it right. Had to set the default for the checkbox to the column in the collection.
@Johnane ok, hopefully this will be a little more helpful for you.
If(
varIsChecked = Blank(),
colChecked,
Filter(
colChecked,
isChecked = varIsChecked
)
)
isChecked is a column in my collection. When the item is checked in the gallery, it patches the collection, setting the isChecked to true. When it is unChecked, it patches the collection setting the isChecked value to false.
// onCheck Code:
Patch(colChecked,ThisItem,{isChecked: true})
// OnUncheck Code:
Patch(colChecked,ThisItem,{isChecked: false})
So the gallery filters based off of those values in the collection:
If(
varIsChecked = Blank(),
colChecked,
Filter(
colChecked,
isChecked = varIsChecked
)
)
I added code comments to walk you through the filtering of the gallery (filtering can be confusing):
* If the user chooses "All items" in the radio button, I set the varChecked variable to Blank() to display all items
* If the user chooses "Checked" in the radio button, I set the varChecked variable to TRUE, and the gallery is filtered to show only Checked items.
* If the user chooses "Unchecked" in the radio button, I set the varChecked variable to FALSE, and the gallery is filtered to show only UnChecked items.
What is the Checked in the Gallery Items?
I do not set the checkbox dynamically on my side. I only drag the control over and check when running the app. How do I identify when a user has checked?
I think I should note that the gallery is populated by a collection from a sql db
@Johnane for this example of how to filter by checked / unchecked, for the checkboxes, I didn't have any code in the checkbox itself. I did, however, have a button on the screen that created some dummy data for the example. I just set two checkbox values to TRUE and the rest to FALSE.
ClearCollect(
colChecked,
{
ID: 1,
Checked: false
},
{
ID: 2,
Checked: true
},
{
ID: 3,
Checked: true
},
{
ID: 4,
Checked: false
}
)
Then I just had the gallery point to that collection.
What was the property you set on the checkbox?
@Johnane Hope this helps...in my example, I created a radio box that has "All Items", "Checked", and "Unchecked".
Step 1: For the radio box, i placed this code in the OnChange property:
If(
Self.Selected.Value = "All Items",
Set(
varIsChecked,
Blank()
),
If(
Self.Selected.Value = "Checked",
Set(
varIsChecked,
true
),
Set(
varIsChecked,
false
)
)
)
Step 2: In the gallery, I placed this code in the Items property:
If(
varIsChecked = Blank(),
colChecked,
Filter(
colChecked,
Checked = varIsChecked
)
)
RESULTS:
When "All Items" is selected:
When "Checked" is selected:
When "Unchecked" is selected:
WarrenBelz
89
Most Valuable Professional
MS.Ragavendar
58
Michael E. Gernaey
42
Super User 2025 Season 1