I have a gallery with a filter attached. As I filter, the gallery changes and "selects" an item on it's own. I will call it "soft-selecting" since the user hasn't actually clicked the item. While filtering, other fields (labels, html-text, etc...) are updated by the soft-selected item. I also have another gallery that gets updated from a collection based on the selected item. However, this gallery will not update until the item is "hard-selected". It's almost like I need a "On Change" action instead on the filtered gallery.
Here are my formulas, etc:
The filtered gallery (PeopleGallery) OnSelect:
Set(person, PeopleGallery.Selected); ClearCollect(emailAndPhones, {
Type: "email", Text: "<a href='mailto:"&PeopleGallery.Selected.email&"'>"&PeopleGallery.Selected.email&"</a>"
}); If(!IsBlank(PeopleGallery.Selected.email2),
Collect(
emailAndPhones, {
Type: "email",
Text: "<a href='mailto:"&PeopleGallery.Selected.email2&"'>"&PeopleGallery.Selected.email2&"</a>"
})); If(!IsBlank(PeopleGallery.Selected.phone_office),
Collect(emailAndPhones,{
Type: "phone",
Text: "<span>Office: "&PeopleGallery.Selected.phone_office&"</span>"
})); If(!IsBlank(PeopleGallery.Selected.phone_cell),
Collect(emailAndPhones,{
Type: "phone",
Text: "<span>Cell: "&PeopleGallery.Selected.phone_cell&"</span>"
}))
Secondary Gallery (EmailAndPhoneGallery): Items = emailAndPhones
Things I've tried that didn't work:
Any help is appreciated. Thanks!
Solved! Go to Solution.
@v-yutliu-msft I decided to take a different route and created indivdual labels/icons groups that appear if there is data since I know I will never have more than 4 items. If there's a way to use the Gallery solution in the future, that would be great. Otherwise, this is good for now.
Hi @gingernins ,
Do you mean that you can not create a collection in the Items property?
Since ClearCollect/Collect is a behaviour function, you can not use it in a Items property.
You could only set this formula to a property about action.
For example, a button's OnSelect, a drop down's OnChange, ect.
Here's a doc about behaviour formula for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-formulas-in-depth
Hi @v-yutliu-msft ,
I am creating a collection in the OnSelect of one Gallery and trying to use it to populate the Items of a second Gallery. The first Gallery allows the user to type in a filter box and it updates automatically as they type. A random item in the first Gallery is highlighted (as if selected) as this is happening and labels on the screen automatically update. However, the second Gallery does not udpate until the user manually clicks on the item in the first gallery. Even though the labels are updating, somehow the second Gallery is not getting the message to be updated until the item is selected. Is it even possible to get the second Gallery to update automatically as the list is filtered?
Thanks!
Hi @gingernins ,
Since you set items of gallery2 by using OnSelect prooerty in Gallery1, you need to "select", then the new data of gallery2 is created.
The key point is "OnSelect" property.
It will only act when you "select", select on time the action act one time.
I suggest you set the formula that you use to gallery2's Items.
Then, it will automatically change according to the selected item of gallery1.
Best regards,
@v-yutliu-msft How would I set the items formula of Gallery 2 using a Collect() function? This causes the behavior formula error. In my first post, I mentioned that a collection is created based on the item from Gallery 1 and that Collection is used as the items for Gallery 2. Where can I collect the items as the search filter happens so that Gallery 2 gets updated? I feel like I am missing something.
@v-yutliu-msft I decided to take a different route and created indivdual labels/icons groups that appear if there is data since I know I will never have more than 4 items. If there's a way to use the Gallery solution in the future, that would be great. Otherwise, this is good for now.
Hi there,
I have got the same issue. My intention was to create a collection with a filter to avoid bringing all the records from the database and clearCollect that same collection depending on what is selected in the gallery. This works fine if I "hard-select" the item in the gallery (do the actual "click") but it doesn't work when I filter/search the gallery and the item is "soft-selected". Even if the value of Gallery.Selected.xxx changes automatically I can't fire the event to clearCollect as I got always the "behavior function in a non-behavior property" error.
I finally had to change the data in my screen and fetch the data from the DB directly with all the conditions instead of using a collection.
It would be nice to trigger an action when a value changes, some sort of "listener". If somebody knows how to do it, please share 🙂
User | Count |
---|---|
125 | |
87 | |
87 | |
75 | |
69 |
User | Count |
---|---|
215 | |
181 | |
140 | |
97 | |
83 |