Hi All,
I have produced an app with a nested gallery.
Gallery 1 points to 'collection A' (a collection names) and contains Gallery 2 and a textbox1 showing the name.
Gallery 2 is nested inside Gallery 1 and contains a textbox2
The contents of textbox2 is equal to textbox1.Text and hence shoudl show the name. Everythign is working ok.
If i add a new name to the collection the gallery will add another iteam (as expected), however the name shown in Textbox2 will equal the name shown in the first iteam in the gallery. the expected behavious would be textbox2.text would equal the new name added to the collection.
Is there a way I can refresh the gallery to show the correct fields?
Solved! Go to Solution.
If I understand correctly:
I've had this situation before and I think it is following the expected behavior. I intuit that what PowerApps is thinking is that the control itself is stored in the first row of Gallery1, even though it is replicated for subsequent rows of the gallery.
I have two solutions, but they are roundabout. I think there could be an easier way if there is something in common between the Items property of the two galleries:
Solution 1:
Change Gallery2.Items to:
AddColumns(youroriginalitems,"helpercolumn",Textbox1.Text)
This means, "In Gallery2, show the items you originally wanted to show, but add a helper column for the respective Textbox1.Text."
Then change Textbox2.Text to:
ThisItem.helpercolumn
This should work because Gallery2's Items property can correctly reference Textbox1 since they are on the same level. Textbox2 has problems referencing Textbox1 because they are at different levels.
Solution2:
Change Textbox2.Text to:
LookUp(Gallery1.AllItems,PrimaryKey=ThisItem.PrimaryKey,Textbox1.Text) or First(Filter(Gallery1.AllItems,PrimaryKey=ThisItem.PrimaryKey)).Textbox1.Text
This means, "Look up the respective record within all the items in Gallery1 that matches the primary key (or whatever unique identifier you use), select the first one and return its respective value in Textbox1.Text." Note that this does mean you need to have something matching between Gallery1 and Gallery2.
The idea is that Textbox2 is now going to try to identify the correct value for Textbox1 using a LookUp.
Let me know how this works out.
If I understand correctly:
I've had this situation before and I think it is following the expected behavior. I intuit that what PowerApps is thinking is that the control itself is stored in the first row of Gallery1, even though it is replicated for subsequent rows of the gallery.
I have two solutions, but they are roundabout. I think there could be an easier way if there is something in common between the Items property of the two galleries:
Solution 1:
Change Gallery2.Items to:
AddColumns(youroriginalitems,"helpercolumn",Textbox1.Text)
This means, "In Gallery2, show the items you originally wanted to show, but add a helper column for the respective Textbox1.Text."
Then change Textbox2.Text to:
ThisItem.helpercolumn
This should work because Gallery2's Items property can correctly reference Textbox1 since they are on the same level. Textbox2 has problems referencing Textbox1 because they are at different levels.
Solution2:
Change Textbox2.Text to:
LookUp(Gallery1.AllItems,PrimaryKey=ThisItem.PrimaryKey,Textbox1.Text) or First(Filter(Gallery1.AllItems,PrimaryKey=ThisItem.PrimaryKey)).Textbox1.Text
This means, "Look up the respective record within all the items in Gallery1 that matches the primary key (or whatever unique identifier you use), select the first one and return its respective value in Textbox1.Text." Note that this does mean you need to have something matching between Gallery1 and Gallery2.
The idea is that Textbox2 is now going to try to identify the correct value for Textbox1 using a LookUp.
Let me know how this works out.
User | Count |
---|---|
158 | |
91 | |
68 | |
63 | |
63 |
User | Count |
---|---|
210 | |
155 | |
93 | |
81 | |
71 |