Hi,
I have a gallery (Gallery 1) that is filtered from the selection of a gallery (Gallery 2) on the previous screen. I have a button that deletes a row from the Gallery 1 (a sharepoint list row). The delete function works fine, but my Gallery 1 is reset to a different selection from Gallery 2. Below is a gif of it happening, notice how the row isn't just deleted but resent to a different data input.
Solved! Go to Solution.
No, Default on a Gallery is a Record ONLY. It is not a table. The table is the Items property, the Default is the EXACT record in that items table to be selected. The default is only one record because you can only have one record selected in a gallery at a time.
The problem now is that the previous gallery is made of multiple records condensed into one gallery item (a formula I believe you help me make yesterday 😝). Below is that formula for the previous galleries selected item:
Is there a way to use this in the default section of the next gallery like that article described?
Yes, this is the root cause. You are changing the Orders list in your delete. Since we have Grouping, Summing, etc. going on in that Items property, PowerApps will re-evaluate the statement and will lose its selected item.
I just replied to a similar issue in this post and you will read there that I mention all of the many conditions that can cause the selection to go away.
Now...in review of your GIF "video", the real issue is that you are referencing the first Gallery.Selected as the Items for your second Gallery. And, as mentioned above, the first Gallery is going to change once you change the Orders datasource as it need to re-calc.
There are 2 tricks to resolving this:
1) is that you're going to need to use the Default property on the Gallery to "re select" the record. How you can do this is through a dreaded variable. When you select an item in the first gallery, you can use a variable to snapshot the ID of record you are selecting - UpdateContext({lclSelectedID:ThisItem.ID}) Then, in your Default you can *repeat* the exact Items property of your Gallery in a LookUp based on the ID in the lclSelectedID variable. If it is all exact, then the record will match and the item will be selected. The disadvantage of it is that it moves the scroll position to the top - i.e. the Top record is selected, but at least it is the one you want.
Also in your scenario, this is going to cause a blip in the second gallery where it will change to the first item in your first gallery briefly and then will change to the selection you were once working on. That is a little annoying and could actually delay enough that it would seriously confuse users.
2) Forget about firstGallery.Selected and instead set a snapshot variable on the selection. Now in the post where we discussed the formula you are using for the Gallery, we dropped the "Items" column at the end. We can actually use that column now. So you can get rid of the DropColumns on the items column. Now, in the OnSelect, you can set a variable, like -
Set(glbItemList, thisItem.items) (note we're using Set because your other Gallery is on another screen, so we need global. This was not a concern in the #1 above because we just needed it on the first screen).
Then, set the Items property of the second Gallery to that variable - glbItemList
Now your second gallery should maintain it's list. HOWEVER, when you delete or edit an item, it is not going to change in the second gallery 😞
SO....what to do (and the reason I am going through all of these scenarios is to give you a better understanding of different ways to solve different situations)?
Here is what you should have on your OnSelect of the first Gallery - Set(glbOrderNumber, ThisItem.Order_x0023_
Then on your Second Gallery, set the Items formula to:
Filter(Orders, Order_x0023_ = glbOrderNumber)
Now, your first gallery is still going to change when you change the Orders list, but now your second gallery is separated from it, so it will not be impacted when the first gallery changes.
I hope that all of this is informative and helpful and ultimate solves the problem you are experiencing.
Alright! First option worked out perfect. Thanks for all the help and explinations
User | Count |
---|---|
183 | |
108 | |
88 | |
44 | |
43 |
User | Count |
---|---|
226 | |
108 | |
105 | |
68 | |
68 |