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
Solved! Go to Solution.
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.
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.
Thanks Tim, Nice simple solution!!!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
259 | |
126 | |
86 | |
85 | |
68 |