cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Impactful Individual
Impactful Individual

Issue with Default Gallery Item

Hi,

 

I have a data source called 'Tickets'
I have a gallery displaying all items and when I select an item I set a global variable called 'SelectedTicket'
On another page I display a filtered gallery of the same items and I want the default selected item of this gallery to be the 'SelectedTicket' from the previous page.

 

The Items for this gallery are:

Filter(Tickets,Contact=SelectedTicket.Contact)

The Default of this gallery is:

LookUp(Tickets,TicketNumber=SelectedTicket.TicketNumber)

From everything I know, this should work but the gallery just always displays the first item even if I do a manual 'reset' from a button.

 

Anyone have any ideas?

Thanks

Sam

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @SamPo ,

 

Now I got you. yes, it won't work when you apply a filter on datasource. Create a Collection with the datasource and filter on that collection, this works. But, please don't ask why (if it works) that is the fix I have seen for the same issue for on my requirement.

 

I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

12 REPLIES 12
Super User III
Super User III

What formula do you have for the variable.

Edited

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Super User III
Super User III

Hi @SamPo ,

 

I have implemented a sample with your scenario, see the below working model and formulas I have used:

Default gallery selection.gif

Formulas on the gallery:

Gallery Default: LookUp(colReported,ID=Dropdown11.Selected.ID)
Items: colReported // This is a collection
TemplateFill: If(ThisItem.IsSelected,RGBA(22, 220, 220, 5), RGBA(242, 242, 242, 5))

on the Edit Form:

Item: First(Filter(SampleList,ID=Gallery25.Selected.ID))


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Impactful Individual
Impactful Individual

@KrishnaV Thanks for the detailed response.

 

When I set the gallery to be just 'Tickets' then this works as expected. When I change the gallery items to be a filter of the data source then it stops working properly. I'm jumping between pages each time this variable is set, don't know if that has something to do with it though I don't see why it should matter.

 

@eka24 I'm just setting this variable from a previous gallery with the following code:

Set(SelectedTicket,LookUp(Tickets,TicketNumber=varTicketNumber))

I know this variable is working as I'm using it in other places and as I said above, this works when I set the gallery to be based just off the data source with no filter.

Impactful Individual
Impactful Individual

Okay, I've found the pattern. It only works if the values of the gallery are updated.

As you can see from my formula I'm looking up a 'contact'. If the contact stays the same (and hence the gallery values stay the same) then the default selection does not update. If I select an item related to another contact (and hence the gallery values do update) then the default selection works.

 

I've tried adding a 'reset' command for the gallery and even put it on a button on the same page so I can manually force it but it doesn't work.

 

Any ideas?

I asked for the Variable because i think there should be an additional variable. I tested this:

  1. Set a Variable in Gallery1

        Set(SelectedTicket,Gallery1.Selected); Set(Selected1,Gallery1.Selected.TicketNumber)

  1. Filter in Gallery2

         Filter(Tickets,Contact = SelectedTicket.Contact)

  1. Default in Gallery2

        LookUp(LookUp, TicketNumber=Selected1)

 

     4. On the Template fill of Gallery2:

If(ThisItem.IsSelected,Green,RGBA(0, 0, 0, 0))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Impactful Individual
Impactful Individual

@eka24 I tried changing the formula as you suggested but it produced the same result as I described above.

When the data in the gallery changes the default value updates correctly. When the data remains the same, it stays on the first value even if I reset the gallery control.

Hi @SamPo ,

 

Now I got you. yes, it won't work when you apply a filter on datasource. Create a Collection with the datasource and filter on that collection, this works. But, please don't ask why (if it works) that is the fix I have seen for the same issue for on my requirement.

 

I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Impactful Individual
Impactful Individual

@KrishnaV  Yes that seems to be the case. I was trying to avoid going down the collection route. In theory this data source could go quite large, I could limit the amount of records shown but prefer not to.

 

I thought it would work on filtered data sources as according to the comment in the solution here by  @Mr-Dang-MSFT : https://powerusers.microsoft.com/t5/Building-Power-Apps/Set-Gallery-Default-based-on-Global-Variable...

 

"The formula above should work if the Gallery's items is spListCollection or some filter on it."

 

According to that statement it should work for filtered items but clearly this doesn't seem to be the case.

 

Thanks

Sam

Hi @SamPo ,

 

Yes, I have tried many many ways but I got the solution only by making it a collection. Please let me know if you see any challenge I am more than happy to help.


Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (30,779)