cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Order gallery items with buttons (arrow up/down)

Hello,

I would like to put the items in a gallery in order with a couple of arrows (up/down). I've tried with a timer but I cannot get it to work. Any easier way? 


Captura.JPG

 

 

 

 

 

 

 

 

 

Regards,

Albert

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Order gallery items with buttons (arrow up/down)

Hi @Anonymous ,

For now, the gallery's order could only sort based on one spefic column and formula.

You could not change one item's position by just cliking a button.

 

So I suggest you add one field to record value , sort items based on this field and then change the field's value by clicking the arrow.

I've made a similar test for your reference:

1)create a collection that adds one new record:   

(Please note that you can not set ClearCollect collection in the gallery's Item property.

You should set it in one behaviour peroperty)

ClearCollect(collection1,AddColumns(tablename,"order",ID))
 //add one field named order, the original data is equal to ID(one exiting field that can represent the items'order)

2)set the gallery's Items:

SortByColumns(
collection1,
"order") //sort items based on order field

3)set the arrow's OnSelect:   //update the value of order field

Up arrow OnSelect: 

Patch(collection1,ThisItem,{order:order-1})

Down arrow OnSelect:

Patch(collection1,ThisItem,{order:order+1})

Then, you could update the order field by clicking the arrows to make the item up/down.821.PNG

 

 

 

 

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

7 REPLIES 7
shailendra74
Level 10

Re: Order gallery items with buttons (arrow up/down)

Hi @Anonymous 

 

Can you show a sample screen shot what you are trying to do.

 

Thanks.

Anonymous
Not applicable

Re: Order gallery items with buttons (arrow up/down)

@shailendra74  I've updated the post with pic.

Should be simple. I have a gallery with several items. But I need to put the different records in order. 

So two arrows, up and down, and this updates the collection to change the display order in the gallery.

Thanks

PavanKumar
Level 8

Re: Order gallery items with buttons (arrow up/down)

Hi,

 

Add custom column called Sort order to your collection and use that column for sorting the gallery.

 

On click of up or down arrow just increment and decrement that value. That simplifies in order to achieve the re-ordering.

 

if this answers your question mark it as verified

Regards,

Pavan Kumar Garlapati

shailendra74
Level 10

Re: Order gallery items with buttons (arrow up/down)

Hi @Anonymous 

 

If you need to sort the gallery on specific column, as @PavanKumar  mentioned, you can have the icons on each column and on click of a icon (column) 

 

UpdateContext({ MYSORTCOLUMN: "column name" }) 

 

 

Items property of the gallery should be as below. 

SortByColumns( mycollection, MYSORTCOLUMN ) // either collection or the sp list

 

Thanks.

Anonymous
Not applicable

Re: Order gallery items with buttons (arrow up/down)

Sorry but this method does not seem to work.

Using UpdateContext({QuestionOrder: QuestionOrder -1}); on the up arrow, and sorting the gallery by column QuestionOrder 

😕

Community Support Team
Community Support Team

Re: Order gallery items with buttons (arrow up/down)

Hi @Anonymous ,

For now, the gallery's order could only sort based on one spefic column and formula.

You could not change one item's position by just cliking a button.

 

So I suggest you add one field to record value , sort items based on this field and then change the field's value by clicking the arrow.

I've made a similar test for your reference:

1)create a collection that adds one new record:   

(Please note that you can not set ClearCollect collection in the gallery's Item property.

You should set it in one behaviour peroperty)

ClearCollect(collection1,AddColumns(tablename,"order",ID))
 //add one field named order, the original data is equal to ID(one exiting field that can represent the items'order)

2)set the gallery's Items:

SortByColumns(
collection1,
"order") //sort items based on order field

3)set the arrow's OnSelect:   //update the value of order field

Up arrow OnSelect: 

Patch(collection1,ThisItem,{order:order-1})

Down arrow OnSelect:

Patch(collection1,ThisItem,{order:order+1})

Then, you could update the order field by clicking the arrows to make the item up/down.821.PNG

 

 

 

 

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

Anonymous
Not applicable

Re: Order gallery items with buttons (arrow up/down)

@v-yutliu-msft Thanks, it kind of works but it gets messy as you end up with repeated  "order" numbers because {order: order+1} does not modify the record next to it to order-1. So you end up with duplicate numbers. 

But if you keep clicking the arrows then well, you eventually get it to work.

 

is there any "ThisItem -1" or something similar?

 

Another option would be to give further separation between each "ID"....

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 (Last 30 Days)
Users online (5,132)