Hi. I need a little assistance with galleries. I have 2 galleries (gallery 1 & 2 in the attached) that contain the same list of items. Selecting an item from either gallery will add that item to a collection. The third gallery shows the contents of the collection. The fourth gallery shows a distinct list of items in the collection. You can see in gallery 3 that apples and cherries appear twice. This is intentional. If I click the trash can in gallery 4 for Apples I want to programmatically uncheck the corresponding item in gallery 1 & 2. This is were I'm stuck. I'm not sure how to locate the item in the gallery and uncheck the checkbox.
The scenario probably would not appear in the real world but I would like to know for my own education.
Any thoughts?
Thanks in advance.
Solved! Go to Solution.
Normally I would not suggest a collection for all of this as the Gallery already serves as a collection. However, in this scenario, you must take "snapshots" of the checkboxes as you go or else you will end up in a circular situation and get an error for that.
So, essentially, for the checkboxes in Gallery1,
OnCheck: Collect(colList1, {Value: ThisItem.Value})
OnUncheck: Remove(colList1, {Value: ThisItem.Value})
Default: ThisItem.Value in colList1
Same thing on the checkboxes in gallery 2, except change the colList1 to colList2.
Then the Items property on Gallery3:
Filter(
Ungroup(
Table({Items: colList1},
{Items: colList2}
),
"Items"
),
!IsBlank(Value)
)
Gallery4 Items:
Distinct(Gallery3.AllItems, Value)
On the OnSelect of the trash icon:
RemoveIf(colList1, Value=ThisItem.Result); RemoveIf(colList2, Value=ThisItem.Result)
Result:
I hope this is helpful for you.
Normally I would not suggest a collection for all of this as the Gallery already serves as a collection. However, in this scenario, you must take "snapshots" of the checkboxes as you go or else you will end up in a circular situation and get an error for that.
So, essentially, for the checkboxes in Gallery1,
OnCheck: Collect(colList1, {Value: ThisItem.Value})
OnUncheck: Remove(colList1, {Value: ThisItem.Value})
Default: ThisItem.Value in colList1
Same thing on the checkboxes in gallery 2, except change the colList1 to colList2.
Then the Items property on Gallery3:
Filter(
Ungroup(
Table({Items: colList1},
{Items: colList2}
),
"Items"
),
!IsBlank(Value)
)
Gallery4 Items:
Distinct(Gallery3.AllItems, Value)
On the OnSelect of the trash icon:
RemoveIf(colList1, Value=ThisItem.Result); RemoveIf(colList2, Value=ThisItem.Result)
Result:
I hope this is helpful for you.
Hi Randy,
This was exactly what I was needing. Thank you.
But now I have another question. You mentioned you would not use a collection for all of this as the Gallery already serves as a collection. I believe that would be more straight forward and could eliminate the need for Gallery 3. How would that change the above example?
Thanks,
Terry
Yes, so just get rid of Gallery 3 and set the Items of Gallery 4 to:
Distinct(
Filter(
Ungroup(
Table({Items: colList1},
{Items: colList2}
),
"Items"
),
!IsBlank(Value)
),
Value)
That gets rid of Gallery 3.
As for the initial checkbox gathering, the collections are needed there as you essentially need an in-memory database to be able to add and remove records...that IS what a collection is - and a proper use for it as well.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
70 | |
50 | |
37 | |
25 |
User | Count |
---|---|
239 | |
112 | |
91 | |
91 | |
68 |