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.
Solved! Go to Solution.
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.
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.
@DavesTechTips 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.
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)
@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.
Your ExpenseCollection...it has an EditMode column in it by definition? It is defaulted to false?
@RandyHayes Correct. I've tried it both ways ... defaulted to true and defaulted to false. It is currently defaulted to false.
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.
1.
2. Gallery Items Property
3. Edit Button appears on every row in the gallery:
4. OnSelect Property of the edit button:
5. DisplayMode on ALL gallery items:
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.
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)
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
200 | |
183 | |
76 | |
46 | |
37 |
User | Count |
---|---|
325 | |
258 | |
123 | |
72 | |
58 |