cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

OnSelect for Gallery not firing when the Items are initially loaded

I have a gallery that needs to perform a few UpdateContexts operations when an Item is selected in the gallery. 

 

 

I also have the TemplateFill setup to highlight the currently selected item;

If(hsl_partsrequestid=PartsRequests.Selected.hsl_partsrequestid,
RGBA(0,0,0,.250), 
RGBA(0,0,0,0)
)

When the screen is shown and the items are loaded into the gallery, the gallery selects the first item (it's highlighted), but the OnSelect is never fired.

 

Does anyone know a way to hook into this event or tell the Gallery not to default the selection to the first item

1 ACCEPTED SOLUTION

Accepted Solutions
TimRohr
Solution Sage
Solution Sage

If what you're worried about is that the Gallery "looks" like it selected the item, but the OnSelect never fired, then just add an UpdateContext({}) to your OnSelect statement, and read that variable in your TemplateFill property.

 

OnSelect:

...whatever code you have, then...

UpdateContext({_initGallery: true})

 

TemplateFill:

If(hsl_partsrequestid=PartsRequests.Selected.hsl_partsrequestid && _initGallery,
RGBA(0,0,0,.250),
RGBA(0,0,0,0)
)

 

That way, it will never look like it is selected until the Gallery has been selected one time. Once you get that, you'll just need to manage resetting the _initGallery to false any time the Gallery would refresh, etc.

View solution in original post

2 REPLIES 2
TimRohr
Solution Sage
Solution Sage

If what you're worried about is that the Gallery "looks" like it selected the item, but the OnSelect never fired, then just add an UpdateContext({}) to your OnSelect statement, and read that variable in your TemplateFill property.

 

OnSelect:

...whatever code you have, then...

UpdateContext({_initGallery: true})

 

TemplateFill:

If(hsl_partsrequestid=PartsRequests.Selected.hsl_partsrequestid && _initGallery,
RGBA(0,0,0,.250),
RGBA(0,0,0,0)
)

 

That way, it will never look like it is selected until the Gallery has been selected one time. Once you get that, you'll just need to manage resetting the _initGallery to false any time the Gallery would refresh, etc.

Anonymous
Not applicable

Thanks Tim,   Nice simple solution!!!

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,503)