Using Galleries for Data Display

Loading

πŸ”Ή Using Galleries for Data Display in Power Apps – A Complete Guide

πŸ“Œ Introduction

A Gallery in Power Apps is a control used to display and interact with multiple records from a data source. It allows users to scroll through data, select items, and apply filters, sorting, and search functions.

βœ… Why Use Galleries?

  • πŸ“‹ Displays multiple records in a structured way.
  • πŸ”„ Supports filtering, sorting, and searching.
  • πŸ“± Works dynamically with different data sources (SharePoint, SQL, Dataverse, etc.).
  • 🎨 Customizable layout and design.

πŸ”Ή Step 1: Adding a Gallery Control

1️⃣ Open Power Apps Studio.
2️⃣ Click Insert β†’ Gallery.
3️⃣ Choose a gallery type:

  • Vertical (default, for lists).
  • Horizontal (for carousels).
  • Flexible Height (for items with variable text sizes).
    4️⃣ Connect to a data source:
  • Select the gallery.
  • Click Properties β†’ Items.
  • Set Items = DataSourceName (e.g., Items = Employees).

πŸ“Œ Now, your gallery is connected and displays data!


πŸ”Ή Step 2: Customizing the Gallery Layout

1️⃣ Select the Gallery β†’ Click Edit Layout.
2️⃣ Choose a pre-defined layout (Title, Title & Subtitle, Image & Title, etc.).
3️⃣ Add or remove controls (Labels, Images, Icons) as needed.
4️⃣ Bind controls to data fields:

  • Select a Label inside the gallery.
  • Set Text = ThisItem.ColumnName (e.g., Text = ThisItem.Name).

πŸ“Œ Now, each record displays correctly inside the gallery!


πŸ”Ή Step 3: Formatting and Styling the Gallery

βœ… Changing Colors & Fonts

  • Select Gallery β†’ Format using the Properties pane.
  • Customize Fill, Border, Font, Color, Padding, etc..
  • Example: TemplateFill = If(ThisItem.IsSelected, RGBA(0, 120, 215, 0.5), White)

βœ… Adjusting Gallery Size

  • Set the Width and Height dynamically: Width = Parent.Width Height = Screen.Height * 0.6

πŸ“Œ This ensures the gallery fits the screen dynamically!


πŸ”Ή Step 4: Adding Search & Filter to the Gallery

βœ… Adding a Search Box

1️⃣ Insert a Text Input (txtSearch).
2️⃣ Modify the gallery’s Items property:

Filter(Employees, StartsWith(Name, txtSearch.Text))

πŸ“Œ Now, users can search for records dynamically!

βœ… Adding a Dropdown Filter

1️⃣ Insert a Dropdown (ddlDepartment).
2️⃣ Set its Items property:

Distinct(Employees, Department)

3️⃣ Modify the gallery’s Items property:

Filter(Employees, Department = ddlDepartment.Selected.Value)

πŸ“Œ Now, users can filter records by department!


πŸ”Ή Step 5: Sorting the Gallery Data

1️⃣ Insert a Sort Icon (icoSort).
2️⃣ Create a Sort Order Variable in OnSelect:

UpdateContext({sortOrder: If(sortOrder="Ascending", "Descending", "Ascending")})

3️⃣ Modify the gallery’s Items property:

Sort(Employees, Name, If(sortOrder="Ascending", Ascending, Descending))

πŸ“Œ Now, clicking the icon toggles sorting order!


πŸ”Ή Step 6: Displaying Images in the Gallery

1️⃣ Add an Image Control inside the gallery.
2️⃣ Set its Image property:

ThisItem.Photo

πŸ“Œ Now, each record displays its associated image!


πŸ”Ή Step 7: Handling Item Selection

1️⃣ Add a Label outside the gallery (lblSelectedName).
2️⃣ Set its Text property:

"Selected: " & Gallery1.Selected.Name

πŸ“Œ Now, clicking an item updates the label with the selected record’s name!


πŸ”Ή Step 8: Adding Navigation from the Gallery

1️⃣ Insert a Button inside the gallery (btnViewDetails).
2️⃣ Set its OnSelect property:

Navigate(DetailsScreen, ScreenTransition.Fade, {selectedItem: ThisItem})

3️⃣ On the Details Screen, set a Label:

Text = selectedItem.Name

πŸ“Œ Now, clicking the button opens a details screen for the selected item!


πŸ”Ή Step 9: Optimizing Performance for Large Datasets

βœ… Use Delegable Functions:

  • Use Filter(), Sort(), and Search() with SharePoint, SQL, Dataverse.
  • Avoid First(), Last(), CountRows() on large datasets.

βœ… Enable Pagination for Large Data:
1️⃣ Add Next and Previous buttons.
2️⃣ Use collections to load data in chunks:

ClearCollect(PageData, Filter(Employees, ID > currentPage * 100 && ID <= (currentPage + 1) * 100))

πŸ“Œ This improves performance when handling large datasets!


πŸ”Ή Step 10: Testing and Deploying the Gallery

βœ… Test on Different Devices

  • Preview (F5) and resize the app window.
  • Use Power Apps Mobile to check layout.

βœ… Publish the App

  • Click File β†’ Save & Publish.

πŸ“Œ Now, your gallery is fully functional and ready for users!


πŸ”Ή Conclusion

A well-designed Gallery in Power Apps enhances data visibility, user interaction, and app performance.

πŸ’‘ Key Takeaways:
βœ… Use dynamic properties for responsive design.
βœ… Add search, filters, and sorting for better usability.
βœ… Optimize performance using delegation and pagination.
βœ… Allow navigation from the gallery for detailed views.

πŸš€ Now, your Power Apps gallery is ready to display data efficiently!


Leave a Reply

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