web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Move selected gallery ...
Power Apps
Unanswered

Move selected gallery item to top

(0) ShareShare
ReportReport
Posted on by 437 Super User 2024 Season 1

Is there a way on a vertical gallery that, when you select a gallery item, have it snap to the top?

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Brian-M,

     

    With a Vertical Gallery (with a scrollbar) you can achieve this with the following code:

    //OnSelect of the Gallery
    UpdateContext({varSelectedRecord: ThisItem});
    //Change GalleryName to the correct name
    Reset(GalleryName)

     

    //Default of the Gallery
    varSelectedRecord

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    Ok, that works perfectly (Thank you!) with one caveat.  I'm trying to convert a gallery into a drop-down list to bypass the 2K record limit on comboboxes.  Everything works perfectly until; after a user selects a name, the name snaps to the top, and then the gallery height adjusts to display just the top record.  That's when the 'snap to top' doesn't work - when the gallery height adjusts.  See attached videos. Any suggestions on how to fix that?

  • Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    Here are two Gifs

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Brian-M,

     

    Big thanks for the Gifs. I did some tests on my end and the functionality worked as expected (also when resizing the gallery):

    //OnSelect of the Gallery
    UpdateContext({varSelectedRecord: ThisItem});
    //Change gallery Height
    UpdateContext({varGalHeight: 50});
    //Change GalleryName to the correct name
    Reset(GalleryName)

    The Gallery Height would be varGalHeight (the arrow icon would e.g. set this to 500) and the Default would still remain varSelectedRecord.

     

    Do note that the Gallery is also limited to a max. of 2000 records (depending on your Data Row Limit). 2000 rows is the general limit of data fetching for Canvas Apps.

     

    I hope this helps!

  • Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    In my test UpdateContext doesn't recognize/find varGalHeight, so I had used Set instead.

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Brian-M,

     

    One thing that comes to mind is: Make sure that you have Select(Parent) in the OnSelect of your label (within the gallery). Otherwise the code in the OnSelect of the Gallery will not run.

     

    I hope this helps!

  • Brian-M Profile Picture
    437 Super User 2024 Season 1 on at

    Thanks for your help on this!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard