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

How to get absolute position of selected item in gallery

I have a gallery on one of my screens in a horizontal arrangement. That is, each item in the gallery has one horizontal row of fields. At the end of the row in the gallery template, I have an icon control that makes an edit form visible. I want the position of this edit form to be on top of the selected gallery item such that the un-selected gallery items are still visible, and the selected item is now hidden behind the edit form.

The X coordinate is easy. I can just set that to [GalleryName].X. I can't figure out how to get the Y coordinate. Since [GalleryName].Selected refers to the selected item data and not the gallery item itself, there is no Y parameter. How can I get the Y position, so the edit form always opens on top of the selected gallery item?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to get absolute position of selected item in gallery

Hi @AIUYM19 ,

Do you want to display an edit form in the position of the selected item in gallery?

I do not think this will work.

Two reasons:

1)If you want to put an edit form on top of the gallery, it's not supported to get every row's position.

(If you scroll the gallery, items' position will change. So there's no property about this.)

2)It's not supported to insert an edit form inside a gallery. So you can not decide the edit form's visibility based on the selected item.

 

However, I've figure out an alternative solution:

insert the controls that you need to use for updating inside the gallery.

Change these controls' visibility based on the selected item.

I've made a similar test for your reference:

1)insert a gallery to display items

2)insert an icon for clicking to edit the item, named Icon1

set Icon1's OnSelect:

ClearCollect(selecteditem,ThisItem)

//save selected item in a collection

3)group the controls in the gallery, in my test is:Icon1, Title1,Subtitle1, named Group5

521.PNG

 

4)insert some controls for updating inside the gallery

I insert two labels, a textinput, a combo box and an icon

set TextInput1's Default:

ThisItem.Name

set ComboBox1's Items:

Choices(testmanies.testone)

set ComboBox1's DefaultSelectedItems:

ThisItem.testone

set Icon2's OnSelect:

Patch(testmanies,ThisItem,{Name:TextInput1.Text,testone:ComboBox1.Selected});Clear(selecteditem)

 //use these controls as the usage of an edit form

5)Group these controls: two labels, a textinput, a combo box and an icon, Named Group2

5211.PNG

 

6)set Group2's Visible:

If(ThisItem in selecteditem,true,false)

set Group5's Visible:

If(ThisItem in selecteditem,false,true)

 

 

Then if you click icon1, the controls for displaying will disappear, the controls for editing will display.

If you click icon2, the data will be updated , the controls for editing will disappear, the controls for displaying will display.

The position is all decided by the selected item.

5212.gif

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: How to get absolute position of selected item in gallery

Hi @AIUYM19 ,

Do you want to display an edit form in the position of the selected item in gallery?

I do not think this will work.

Two reasons:

1)If you want to put an edit form on top of the gallery, it's not supported to get every row's position.

(If you scroll the gallery, items' position will change. So there's no property about this.)

2)It's not supported to insert an edit form inside a gallery. So you can not decide the edit form's visibility based on the selected item.

 

However, I've figure out an alternative solution:

insert the controls that you need to use for updating inside the gallery.

Change these controls' visibility based on the selected item.

I've made a similar test for your reference:

1)insert a gallery to display items

2)insert an icon for clicking to edit the item, named Icon1

set Icon1's OnSelect:

ClearCollect(selecteditem,ThisItem)

//save selected item in a collection

3)group the controls in the gallery, in my test is:Icon1, Title1,Subtitle1, named Group5

521.PNG

 

4)insert some controls for updating inside the gallery

I insert two labels, a textinput, a combo box and an icon

set TextInput1's Default:

ThisItem.Name

set ComboBox1's Items:

Choices(testmanies.testone)

set ComboBox1's DefaultSelectedItems:

ThisItem.testone

set Icon2's OnSelect:

Patch(testmanies,ThisItem,{Name:TextInput1.Text,testone:ComboBox1.Selected});Clear(selecteditem)

 //use these controls as the usage of an edit form

5)Group these controls: two labels, a textinput, a combo box and an icon, Named Group2

5211.PNG

 

6)set Group2's Visible:

If(ThisItem in selecteditem,true,false)

set Group5's Visible:

If(ThisItem in selecteditem,false,true)

 

 

Then if you click icon1, the controls for displaying will disappear, the controls for editing will display.

If you click icon2, the data will be updated , the controls for editing will disappear, the controls for displaying will display.

The position is all decided by the selected item.

5212.gif

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper I
Helper I

Re: How to get absolute position of selected item in gallery

Yes, I think this is precisely the behaviour I want! 😃 Let me try in my app, and I will let you know the result...

Highlighted
Community Support
Community Support

Re: How to get absolute position of selected item in gallery

Hi @AIUYM19 ,

Have you succeeded?

If you do not have any problems, could you mark my answer as your solution?

Thanks!

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper I
Helper I

Re: How to get absolute position of selected item in gallery

@v-yutliu-msft 

I apologize for the delay in my reply. Long holiday weekend, and lots of work prevented me from looking at this.

Your method seems to have worked exactly as I hoped. Thank you!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,433)