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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,683)