Ultimate Guide to Power Apps Data Table: Features, Best Practices & Gallery Comparison

Power Apps offers two main controls for displaying data lists: “Gallery” and “Data Table.”
In this article, I’ll share my detailed investigation of the “Data Table” control, including its usage and key differences from the Gallery control.

スポンサーリンク

Data Table

The Data Table control allows you to display data in an Excel-like tabular format.

For example, when connected to SharePoint list, it displays like this:
While I encourage you to check the official documentation for complete details, here are the main characteristics of the Data Table:

  • Single selection only (multiple selection not supported)
  • Adjustable column widths (changes not preserved)
  • Hyperlink display and navigation support
  • Automatic header generation
  • Bi-directional scrollbars (vertical and horizontal)

Official documentation available here

Basic Usage

Using the Data Table is very straightforward. First, add a Data Table control
Then set your data source in the Items property.
Next, simply select the fields you want to display through “Edit Fields” to show your data in tabular format.
How convenient!
You can also display SharePoint lists. For example, with this SharePoint list:
When connected using the SharePoint connector, it displays like this:

Data Selection Capability

Since the Data Table maintains its selection state, you can place a form connected to the same data source alongside it:
By connecting the form’s Item property to the Data Table’s Selected property, you can display the selected data in the form.

Choosing Between “Gallery” and “Data Table”

When deciding between two list-view controls in Power Apps, here’s what you need to consider.

General guidelines for choosing between the two:

  • Data Table: When you need minimal UI customization but display large amounts of data
  • Gallery: When you want detailed UI customization but display moderate amounts of data

Let’s examine the key differences in detail.

Scrollbar Behavior Differences

First, let’s look at how scrollbars differ:

  • Gallery: Vertical OR Horizontal
  • Data Table: Both Vertical AND Horizontal
In this image, the top shows a Data Table and the bottom shows a Gallery configured to mimic a data table. The scrollbar difference is immediately apparent:
Data Table appears to be the better choice when displaying information that extends both horizontally and vertically.
Update (August 5, 2023):
Gallery now supports both vertical and horizontal scrolling, making it capable of meeting the above requirements as well.
Power Apps Gallery scrollable both horizontally and vertically|Display vertical and horizontal scroll bars in Gallery
I implemented this because it became necessary to scroll the gallery both horizontally and vertically.What we want to do...

Visual Customization Options

When it comes to visual customization, Gallery significantly outperforms Data Table.

As shown here, you can add images, buttons, and specify OnSelect for each control individually.

Gallery is the better choice when you need an aesthetically pleasing display of list data.

Column Addition – Data Table’s LookUp Limitation

For example, if you have a master list in SharePoint like this:

When you want to add a column to display employee numbers in your Power Apps screen:

With Gallery, you can simply use LookUp to pull the data:
However, using the same LookUp expression in Data Table causes unexpected behavior…
Instead, you need to modify the data itself using functions like AddColumns before setting it to Items.

Gallery offers more flexibility when you need to perform operations on individual list items.

Data Table’s External Items Access Limitation

It appears that Data Table doesn’t allow external access to its displayed data.

For example, when counting displayed items, Gallery allows you to use the AllItems property like this:

While Gallery allows loop processing by combining ForAll function with the AllItems property, Data Table appears to lack an equivalent property.

Therefore, to count items in a Data Table, you need to count the same data that’s fed into the Data Table’s Items property.

Conclusion

As mentioned at the beginning, here’s when to use each control:
Choose Data Table when handling large amounts of data that doesn’t require detailed UI customization or individual data access.
Choose Gallery when you need detailed UI customization, require access to individual items, or are handling smaller amounts of data.

Note: Based on personal experience, Data Table seems to offer faster display speeds (though this is purely subjective).

Related Article

コメント

Copied title and URL