cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pjames43
Helper I
Helper I

Select Parent of Parent

I am trying to use a container in my gallery view. I am going to be honest, so far the container feel a little useless. I cannot use them in a form, and now they seem unusable inside a gallery. The issue is that I want to put three buttons in a horizontal container so that they display nicely across any screen width. However, now the Container is the Parent of my buttons, and I cannot figure out to make them select the Gallery button. I assumed that Parent.Parent would work, but Parent doesn't see to be a Property in that sense.

 

Any suggestions?

 

I am posting a lot of questions because I am really struggling with how obfuscated a lot things feel in Power Apps as some one who is used to just writing code. Sorry about that.

4 REPLIES 4
RandyHayes
Super User
Super User

@Pjames43 

Yes, the more you look at PowerApps design as "Development" the harder it will be and the more obfuscated things will seem!  Leave the developer hat at the door!

 

A container is usable in the gallery.  If you have a need to select something about the Parent of the Container, then no, Parent.Parent is not viable as Parent is an untyped property and is only specific to the current control.  

 

Is there something specific in the Gallery you want to select?  If so, then simply use the Select function to do so.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Pjames43
Helper I
Helper I

So, if I have button that wants to select the Gallery item it exists on, I set it to Select(Parent), but if I put that button inside a container, how do I select what is now the Parent of the container? It feels very obfuscated.

RandyHayes
Super User
Super User

@Pjames43 

It is already selected!  When you select anything in the Gallery (in a container or not), then it will already have selected the Gallery row.

 

The purpose of the Select(Parent) is ONLY when you have a control with an OnSelect action (formula or not) AND you have a formula in the OnSelect of the Gallery.

 

So, for example, if you have a gallery with a button in it and there is NO formula in the OnSelect action of the button, but there is a Formula in the OnSelect of the Gallery, then the OnSelect of the Gallery will not evaluate.  If you add a Select(Parent) to the Button OnSelect action, then it will perform the action in the OnSelect of the Gallery.

 

The distinction here is that, if anything is selected in a Gallery, the Gallery will select that row.  However, it will not perform an action unless there exists one on the control clicked or the gallery if there is an OnSelect.

 

It's a little hard to describe completely, so the following animation should provide some clarity.

Pjames43.gif

The Gallery has an OnSelect that simply sets a variable to the Item Value shown.  The formula is:

   UpdateContext({SelectedItem:ThisItem.Value})

 

The Label below the Gallery (in Purple) has a Text property of: "Selected Item: " & Coalesce(SelectedItem, "none")

 

Starting with the Label IN the gallery - The Label with the Item Value (A, B, C) has an OnSelect of Select(Parent)

When the label is clicked, the gallery row is selected and the OnSelect action of the label occurs which then selects the OnSelect of the Gallery (evident by the Selected Item label change).

 

Next the Pencil Icon - The Pencil Icon has an OnSelect that is empty

You will see that when that Pencil Icon is selected - the Gallery Row selection changes, BUT, the OnSelect of the Gallery itself does not happen (evident by the label at the bottom).  

 

Next the Plus Icon - The Plus Icon has the following in the OnSelect action:

  UpdateContext({PlusItem: "Plus Selected on Item " & ThisItem.Value})

There is another label at the bottom of the screen (in Orange) that has a Text property of PlusItem

You can see that when the plus icon is selected, the label at the bottom reflects the plus selection and the Item selection does not show the item selected...this is because the formula in the OnSelect did not perform a Select(Parent), so the Gallery formula to set the bbb variable did not occur, on the other one.

You will also notice that the Gallery row selection itself did occur - just no action formula.

 

Finally, there is a horizontal container (yellow fill).  It does not have an OnSelect action, so it cannot participate with actions when it is clicked.  HOWEVER, the Gallery still sees that the row gets selected, just like the Plus icon above.

 

There is a Button in the container that has an OnSelect action of: Select(Icon1) (which is the pencil icon)

When the icon is clicked, it will select the pencil icon which then selects the parent (gallery) and the OnSelect of the Gallery occurs.

 

So, there are a lot of options with that which all have special uses and flexibility in the app.

 

Hopefully that helps clear it up.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes , intersting.

Dumb question: How exactly is the Gallery control being selected, without it's OnSelect firing? Or maybe the question is 'Why"...

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,653)