Default Record

By default, when a screen containing a Gallery is loaded, the first item in the Gallery is automatically selected. Sometimes this is helpful and sometimes not

If you prefer to not have any record selected when the screen loads, simply change the Gallery’s Default property to

{}

If instead you want the default selection to be an item other that the first record, then change the Galleries default property to something like

LookUp(Libraries,'Book ID'="123")

Now, when the screen loads, the record you specified will be selected and if the Gallery contains enough items to display a scroll bar, then the default item you selected will be displayed at the top of the Gallery

Displaying a Gallery ‘Scroll to the Top’ Button

Galleries have a property called VisibleIndex. This is a read-only numerical property that defines which item is at the top of the viewable gallery

When the screen containing a Gallery is loaded, by default, the first item will be displayed at the top of the gallery and the VisibleIndex will be 1. As you scroll down the gallery, the VisibleIndex automatically changes to the item number that is viewable at the top of the gallery. Note that the VisibleIndex is independent of the selected item

The VisibleIndex is a great way of identifying if the user has scrolled the gallery. If the VisibleIndex has a value of 2, the user has scrolled down one item. If the gallery can display 8 items and the VisibleIndex has a value of 8, then that is the equivalent of the user having hit the ‘page down’ button

To display a ‘jump to the top’ Button or Icon, create an Icon on the screen with its OnSelect property set to

Reset(Gallery1)

You may want the Button to only be visible when the user has scrolled down by at least one ‘page’. If this is the case, for the example above where 8 items are viewable in the Gallery, set the Visible property of the Button to

Gallery1.VisibleIndex >= 8

Bear in mind that in order for the gallery to be reset, it needs a Default item to reset to, so if you want the Gallery to not have a default item when the screen loads, but to also have a ‘jump to the top’ Button, set the Default property of the gallery to

If(Gallery1.VisibleIndex > 1, Blank(), {})

Now, both when the screen first loads and when the Gallery is reset, the first item will be visible at the top of the Gallery but it won’t be selected

Summary

With the Default property, you can decide if you want the first item in a Gallery to be automatically selected, or not, when the screen loads

 

A Gallery’s VisibleIndex property displays the number of the item at the top of the viewable Gallery, and can be used to establish whether a user has scrolled the Gallery

 

By using the Default and VisibleIndex properties of a Gallery, the Gallery can be reset so the first item is displayed at the top of the Gallery, even if you don’t want it to be selected

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top