cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JvandeKraats
Frequent Visitor

Power Apps - Move items up and down in a gallery, after deleting an item from the gallery; How can you do this?

Hello,

 

@aprildunnam shows in this nice video (Youtube link)how to organize items in a gallery (up, down, delete). Seems like a good example, because the individual actions are going well. Unless you first delete an item somewhere in the middle and then try to move the one directly below it up. Then it will fail.

 

Who has a solution to this problem?

 

Thanks & greetings from the Netherlands!

 

Jorne

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @JvandeKraats :

I suggest you set the Trash icon's OnSelelct property to:

 

Set(TheOrder,ThisItem.Order); /*TheOrder is my custom variable*/
Remove(agenda,ThisItem);
UpdateIf(agenda,Order>=TheOrder,{Order:Order-1})

 

Doing so can ensure that the order of all items are continuous.

Best Regards,

Bof

View solution in original post

3 REPLIES 3
v-bofeng-msft
Community Support
Community Support

Hi @JvandeKraats :

I suggest you set the Trash icon's OnSelelct property to:

 

Set(TheOrder,ThisItem.Order); /*TheOrder is my custom variable*/
Remove(agenda,ThisItem);
UpdateIf(agenda,Order>=TheOrder,{Order:Order-1})

 

Doing so can ensure that the order of all items are continuous.

Best Regards,

Bof

Dear Bof,

 

Thank you for the simple, but great solution for my problem.

Have a nice day!

 

Best regards,

 

Jorne

RTB_10
Helper I
Helper I

Found another solution which doesn't involve having to remove all the items when something is deleted. 

 

Because April's method depends on all the order numbers being in a sequential order it fails when items get deleted. However, on Shane's YouTube channel he has a video which shows how to update a column with new row numbers even when items are removed. See here: PowerApps Tracker App including Add row numbers to a gallery.

 

So to get this to work with April's method I just added a step to update the row numbers each time a selection is made. Now item's can get ordered and removed at the same time!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,121)