I have a gallery where a Reset is triggered by a toggle button that will show/hide certain records. I want a "Processing" dialog to show up while the reset happens. I added this to the "OnChange" of the toggle, but it does nothing visually.
UpdateContext({varShowProcessing: true});
Reset(galItemSelection);
UpdateContext({varShowProcessing: false})
What I am pretty sure is happening is the variable is set to true, the reset is triggered, and immediately the variable is set back to false.
Is there a way to wait for the reset to finish?
I've added a timer, but that is a bad solution. Sometimes the reset takes a second or so, and other times 5+ seconds depending on the data, connection, etc, and it looks silly for the "Processing...." dialog to be there blocking the user when the data has obviously refreshed, and just as silly to have the dialog disappear and the refreshing is still happening.
@WarrenBelz
Sometimes I just can't read, maybe because @asifkhawaja said 'count of the gallery'. Somehow I saw that as:
CountRows(GalleryName.AllItems) = 0
instead of:
GalleryName.AllItems = 0
And now I'm completely puzzled.
I would expect GalleryName.AllItems to return a table, since it is a collection, not a integer number.
I will try this ASAP.
@MichelH ,
Mine refers to (and works very well) when a gallery needs to initially resolve its Items directly from a data source on screen opening and has multiple Filters. You are correct if you are updating a collection that this will not work.
I doubt this will work as expected if you are updating the collection behind a gallery, which I believe EdHansberry is doing. You might as well launch the timer when you start updating. Problem is you don't know how long it will take.
Given that we no longer can rely on a sequential execution of the gallery update, I think I need to adapt my previous suggestion, by testing if the minimum TS on the gallery equals the last timestamp.
So I have a Toggle with this as the Toggle.Default:
Min(Gallery.AllItems, TScolumn) = TS
And the code I need, under the Toggle.OnCheck
Br,
Michel
I actually found one that works quite well - similar to @asifkhawaja , but without the timer. I have a spinner with the Visible
CountRows(GalleryName.AllItems) = 0
It is visible while the gallery is loading and disappears as soon as it fills
You can do this using a Timer control. Set timer to 1 second (or half a second etc). Then every 1 second (or half a second) check if the count of the gallery is not 0. If it is 0, continue; if it is not, stop the timer. And on the timer end event, perform whatever actions you need to, including refreshing any variables.
Hope that gives some ideas.
@EdHansberry
Hi Ed,
I'm facing a similar situation where I need to recalculate some variables using data from the gallery, and this must be done when the gallery has finished loading or finished updating. So like you I'm looking for an event that says just this.
Did you find a solution for this?
I was thinking to use an Now() seconds+msec timestamp TS, and to add a column that holds this timestamp and test if the Last( Gallery.AllItems entry for that column, has the value that matches the timestamp, but I still hope a more elegant solution is possible.
When I put this in the Default property of a toggle control: Last(Gallery.AllItems).TS = TS
Power Apps insists I'm creating a circular reference.
Moving the toggle control to the screen, instead of a form and the "circular reference" is gone.
Best Regards,
Michel
Unfortunately that doesn't really do it. I see what you are doing but that is an entirely different screen. Power Apps clearly knows when data is being refreshed because the marching ants go across the top, but there is, AFAIK, no way to have a more visible spinner or even a dialog box blocking interaction until the gallery refreshes.
Hi @EdHansberry ,
You got me thinking on this and I have a bit of as sneaky workaround that I think does the job.
Do a new blank screen with the background RGBA( 230, 230, 230, 0.5) and put the spinner in the middle.
Navigate to this screen at the start of the code with Transition.Fade and then back again to your screen with the same transition.
Screen fades to spinner and then fades in again at code end.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
I've made changes to the LoadingSpinner property and the related .Color property and nothing is happening. I don't think a refresh of the Gallery screen is trappable. Loading yes, but not just changing what is show by changing the FILTER() function in the Items property. 😐
I've looked through several threads in this forum and watched 2 youtube videos. Everything is about loading the gallery when the screen changes, not when the gallery is re-reading data. The marching ants are working across the top, but that is too hidden to the average user, and LoadingSpinner doesn't recognize that aspect that I can tell.