cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
paulculmsee
Level 8

Efficiency of the gallery

I have been developing a safety inspection app for a remote site. I make a lot of use of in-memory collections and caching, and data is sumbitted to flow, rather than a direct connection to a data source.

 

The inspection list is a gallery and I have crafted some radio buttons that allow a user to set a pass/fail/NA for each checklist item. The collection (called CheckListResults) looks as follows and is bound to controls in the gallery.

 

{ ID: 1, LABEL:"Oil level", CHECK:"", CorrectiveAction: "" }, { ID: 2, LABEL:"Seat Belts", CHECK:"", CorrectiveAction: "" }

 

The radiobuttons are using updateIF to update this collection.  

 

Capture.PNG

Now this is all working nicely. User can mark a checklist item as pass/fail. The onselected property for the pass button does the followjng:

 

UpdateIf(CheckListResults,ID=ThisItem.ID,{CHECK: "Pass"})

 

The fail and NA controls do something similar. If "fail" is selected an additional textbox appears where the user can add corrective action detail. FOr this reason I am using a gallery that has a flexible size.

 

As I said, this site is bandwidth limited, so I do it this way because I can persist all this to cache and submit it to SharePoint via Flow when the inspection is complete.

 

The issue I am having have is when the gallery scrolls. If I scroll down to say, checklist item 11 and set it to pass or fail, the entire gallery flickers and on the refresh, the control has scrolled back up to the top. Interestingly, the selected property is still correct - ie the entry I updated is highlighted, but it is now off screen and I have to re-scroll back to see the change.

 

As you can imagine this is an annoying user experience and I am trying to think of ways I can deal with this. 

 

I tried replacing UpdateIF with patch but this seemed to make the problem woirse. Are there any other elegent ways to update a field in a collection?

 

regards

 

Paul

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Level 10

Re: Efficiency of the gallery


@Anonymous wrote:

If I am understanding your post, you are updating the collection every time someone selects an option. That is why the gallery flickers when you update the collection, because you are updating the collection that it is showing so it must reload the entire collection. 


 

This sounds right. The gallery is flickering because you're making live changes to collection in the Items property.

 

I would suggest that you Collect changes you make to your collection (Collection1) to a second collection (Collection2). Objects in the existing gallery can reference their respective records in the second collection. Then when you are ready, commit the changes with a Submit button like @Anonymous suggested.

 

You can use ForAll(Collection2, UpdateIf(Collection1,conditions that match which record is which,{field: data}))

Microsoft Employee
@8bitclassroom
4 REPLIES 4
paulculmsee
Level 8

Re: Efficiency of the gallery

I should also mention that they are not true radiobuttons because of the horizontal orientation. They are images that are stored in a collection. The image property is set as follows:

 

If(ThisItem.CHECK="Pass",iconselected,icon)

 

iconselected and icon are in the media library

Anonymous
Not applicable

Re: Efficiency of the gallery

If I am understanding your post, you are updating the collection every time someone selects an option. That is why the gallery flickers when you update the collection, because you are updating the collection that it is showing so it must reload the entire collection. 

 

The way fix this is to not update the collection until the user selects Submit. When the user selects Sumbit, you can retrieve the item gallery properties and update the collection. If you use check boxes instead of radio button images you can set onCheck and onUncheck properites to set the other check boxes in that record to false.

 

If you loop through Gallery.AllItems, you can see all of the Items and the associated controls. You can see which checkbox was selected. 

mr-dang
Level 10

Re: Efficiency of the gallery


@Anonymous wrote:

If I am understanding your post, you are updating the collection every time someone selects an option. That is why the gallery flickers when you update the collection, because you are updating the collection that it is showing so it must reload the entire collection. 


 

This sounds right. The gallery is flickering because you're making live changes to collection in the Items property.

 

I would suggest that you Collect changes you make to your collection (Collection1) to a second collection (Collection2). Objects in the existing gallery can reference their respective records in the second collection. Then when you are ready, commit the changes with a Submit button like @Anonymous suggested.

 

You can use ForAll(Collection2, UpdateIf(Collection1,conditions that match which record is which,{field: data}))

Microsoft Employee
@8bitclassroom
Highlighted
paulculmsee
Level 8

Re: Efficiency of the gallery

Thanks guys...this was the approach I was learning to so glad to get it confirmed

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 47 members 4,968 guests
Please welcome our newest community members: