cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
modernoddity
Level: Powered On

Edit only selected item in Gallery

I am displaying data from a collection within a gallery and have set it up so users can edit, save, or delete records. However, I cannot seem to figure out how to get it so that ONLY the line item selected is changed to edit mode while the other records stay as view only. Right now when I select the edit button, all items become editable. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Edit only selected item in Gallery

@modernoddity 

Let's go down the list:

1. ExpenseCollection is defined with an EditMode column set to false? Yes

2. Gallery Items property is set to ExpenseCollection?

3. Edit button appears on every row in your Gallery when you play the app?

4. OnSelect property of the edit button is set to : Patch(ExpenseCollection, ThisItem, {EditMode: true})?

5. DisplayMode proeprty of any item you want to change within that gallery template is set to If(ThisItem.EditMode, Edit, View)?

 

Got to this point in the questions and it's still an issue??

Try that test you did before - Put a button on your screen and set it to UpdateContext({EditMode:true}) does everything go to Edit mode?  If so, recheck #5 above.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

18 REPLIES 18
Dawidvh
Level 10

Re: Edit only selected item in Gallery

Hi @modernoddity 

 

From the sounds of things you are updating a variable to specify if the gallery should be editable or not, and then all the controls in the gallery is listening to that item.

 

You will have to add a column in the collection to keep track which items are set to edit mode (something like editMode), and then update the controls to only be editable if ThisItem.editMode is true.

 

Let me know if you don't come right.

 

Dawid van Heerden

Twitter: @davestechtips

YouTube: https://www.youtube.com/davestechtips

**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.

modernoddity
Level: Powered On

Re: Edit only selected item in Gallery

@Dawidvh thank you 🙂 I tried that earlier but it's not working for me. I have a button they have to click to record the entry which has the Collect code in there with the added "EditMode:false" field. The edit button in the gallery has the following OnSelect code: Patch(ExpenseCollection,ThisItem,{EditMode:true}) and each field in the gallery has the following code in the DisplayMode field: If(EditMode=true, DisplayMode.Edit,DisplayMode.View)

 

When I click on Edit with all the code as listed above, absolutely nothing happens. When I change the edit button OnSelect Code to: UpdateContext({EditMode:True}) Everything switches to edit mode. 

 

I'm really new to PowerApps so this is boggling my mind lol. 

Super User
Super User

Re: Edit only selected item in Gallery

@modernoddity 

If your gallery is based on the ExpenseCollection that you are patching, then consider changing your DisplayMode properties on the fields to:

If(ThisItem.EditMode=true, DisplayMode.Edit,DisplayMode.View)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
modernoddity
Level: Powered On

Re: Edit only selected item in Gallery

@RandyHayes Thank you for the suggestion. I just gave that a shot and when I hit the edit button, nothing happened. I'm not sure what I'm doing wrong here. Seems like either of these solutions should definitely work. 

Super User
Super User

Re: Edit only selected item in Gallery

@modernoddity 

Your ExpenseCollection...it has an EditMode column in it by definition?  It is defaulted to false?

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
modernoddity
Level: Powered On

Re: Edit only selected item in Gallery

@RandyHayes Correct. I've tried it both ways ... defaulted to true and defaulted to false. It is currently defaulted to false. Screenshot_2.png

Super User
Super User

Re: Edit only selected item in Gallery

@modernoddity 

Let's go down the list:

1. ExpenseCollection is defined with an EditMode column set to false? Yes

2. Gallery Items property is set to ExpenseCollection?

3. Edit button appears on every row in your Gallery when you play the app?

4. OnSelect property of the edit button is set to : Patch(ExpenseCollection, ThisItem, {EditMode: true})?

5. DisplayMode proeprty of any item you want to change within that gallery template is set to If(ThisItem.EditMode, Edit, View)?

 

Got to this point in the questions and it's still an issue??

Try that test you did before - Put a button on your screen and set it to UpdateContext({EditMode:true}) does everything go to Edit mode?  If so, recheck #5 above.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

modernoddity
Level: Powered On

Re: Edit only selected item in Gallery

1. 1.png 

 

2. Gallery Items Property2.png

 

3. Edit Button appears on every row in the gallery: 

3.png

 

 

4. OnSelect Property of the edit button: 

4.png

 

5. DisplayMode on ALL gallery items: 

5.png

 

TESTING: set up an edit button in the gallery w/ OnSelect property of UpdateContext({EditMode:true}). Nothing happened. However, if I go back and change the DisplayMode property of each item in the gallery to: If(EditMode,DisplayMode.Edit,View), all items in the gallery switch to edit view. 

 

 

Super User
Super User

Re: Edit only selected item in Gallery

@modernoddity 

Okay...check check check on all the items...so, what is next?

As for the test, yes changing the displaymode property would have done that...but it defintiely should be ThisItem.EditMode. The real test in that was to make sure that it was.

 

Let's do two things:

1)  Put a Label on your screen (not in the gallery) and set the Text property to yourGalleryName.Selected.EditMode

It should display "false", when you click on an edit button, it should change to "true".  Yes?

2) Click on an item to edit, then, go into your collection viewer (View->Collections) and look at your collection records and specifically the EditMode column...has the value changed for the item you chose to edit (hopefully it's within the first 5 recrods)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 421 members 6,789 guests
Please welcome our newest community members: