cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnthonyPhan
Kudo Kingpin
Kudo Kingpin

Nested gallery problem

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?

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Community Champion
Community Champion

If I understand correctly:

  • Textbox2.Text is showing the Text for the first item in Gallery1 for all items rather than the respective Textbox1.Text.

 

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:

  1. Add a helper column to Gallery2 to show the respective record
  2. Change Textbox2.Text to reference a LookUp to the respective record

 

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.

Microsoft Employee
@8bitclassroom

View solution in original post

2 REPLIES 2
mr-dang
Community Champion
Community Champion

If I understand correctly:

  • Textbox2.Text is showing the Text for the first item in Gallery1 for all items rather than the respective Textbox1.Text.

 

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:

  1. Add a helper column to Gallery2 to show the respective record
  2. Change Textbox2.Text to reference a LookUp to the respective record

 

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.

Microsoft Employee
@8bitclassroom

View solution in original post

Hi Mr-Dang Thank you for your response. I was able to solve the problem using solution 1. In my opinion this is the more elegant solution. As for your comment about this following the expected behaviour, I would disagree. If a row already exists within the collection prior to running the app it will reference the correct text box, however if it is added later (during run time) it reference the first row of the gallery.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,637)