RepeatingTable in PowerApps

Loading

In PowerApps, a Repeating Table is a way to display a collection of data in a tabular format where each row represents an item from the data source. It is commonly used to show records from a data source like a SharePoint list, Excel table, SQL database, or any other collection.


How to Create a Repeating Table in PowerApps:

  1. Add a Data Source:
  • Connect your app to a data source (e.g., SharePoint list, Excel file, SQL table, or a collection).
  1. Insert a Gallery Control:
  • Go to the Insert tab and select a Gallery control (e.g., Vertical or Horizontal Gallery).
  • Set the Items property of the gallery to your data source (e.g., SharePointListName or CollectionName).
  1. Customize the Gallery Layout:
  • By default, the gallery will display a single column. To create a table-like layout:
    • Add labels or other controls inside the gallery template.
    • Bind the Text property of each label to the fields in your data source (e.g., ThisItem.ColumnName).
  1. Add Headers:
  • To create column headers, add labels above the gallery and set their Text properties to the column names.
  1. Adjust Styling:
  • Customize the appearance of the gallery and labels (e.g., font size, colors, borders) to make it look like a table.

Example: Displaying a SharePoint List in a Repeating Table

  1. Connect to SharePoint:
  • Add a connection to your SharePoint list (e.g., MySharePointList).
  1. Insert a Gallery:
  • Insert a Vertical Gallery and set its Items property to MySharePointList.
  1. Add Labels for Data:
  • Inside the gallery, add labels and set their Text properties to:
    • ThisItem.Title (for the Title column)
    • ThisItem.Description (for the Description column)
    • ThisItem.Created (for the Created Date column)
  1. Add Headers:
  • Add labels above the gallery for headers (e.g., “Title”, “Description”, “Created Date”).
  1. Styling:
  • Adjust the gallery’s TemplateSize and label properties to align the data properly.

Key Properties for a Repeating Table:

  • Gallery Properties:
  • Items: Set to the data source (e.g., MySharePointList or CollectionName).
  • TemplateSize: Adjust the height of each row.
  • WrapCount: Set to 1 for a single column layout.
  • Label Properties:
  • Text: Bind to the data source fields (e.g., ThisItem.ColumnName).
  • Width and Height: Adjust to fit the table layout.

Advanced Features:

  1. Sorting and Filtering:
  • Use the Sort and Filter functions in the Items property of the gallery to display sorted or filtered data.
  • Example:
    powerapps Sort(MySharePointList, Created, Descending)
  1. Search Functionality:
  • Add a search box and use the Search function to filter the gallery dynamically.
  • Example:
    powerapps Search(MySharePointList, SearchBox.Text, "Title")
  1. Pagination:
  • Use the FirstN and LastN functions to implement pagination for large datasets.
  1. Edit and Delete Rows:
  • Add buttons inside the gallery to edit or delete rows using the Patch and Remove functions.

Example Code for a Repeating Table:

// Set the Items property of the gallery
Gallery.Items = ColEmpData(Collection)

// Add labels (or TextInputs) inside the gallery for each column
TextInput1.Text = ThisItem.EmpName
TextInput2.Text = ThisItem.EmpID
DatePicker1.SelectedDate = ThisItem.JoiningDate
ComboBox1.Value = ThisItem.Designation
TextInput3.Text = ThisItem.EmpDescription

// Add headers above the gallery
HeaderLabel1.Text = “S.No”
HeaderLabel2.Text = “EmpName”
HeaderLabel3.Text = “EmpID”
HeaderLabel4.Text = “Designation”
HeaderLabel5.Text = “JoiningDate”
HeaderLabel6.Text = “EmpDescription”

// Add the plus icon and code for the Add icon
// OnSelect property of the add (+) icon
OnSelect = Collect(
ColEmpData,
{
SerialNumber: Last(ColEmpData).SerialNumber + 1,
EmpName: Blank(),
EmpID: Blank(),
Designation: Blank(),
JoiningDate: Blank(),
EmpDescription: Blank()
}
)

// Add the Delete icon (Trim) and code for the Delete icon
// OnSelect property of the delete (Trim) icon
OnSelect = Remove(ColEmpData, ThisItem)



//Add a button for submitting the data and the necessary code to handle the button’s functionality when the ‘Select Property’ option is chosen.

Key Takeaways:

  • A Repeating Table in PowerApps is created using a Gallery control.
  • Bind the gallery to a data source and customize the layout to display data in a tabular format.
  • Use labels for headers and data fields.
  • Enhance functionality with sorting, filtering, search, and pagination.

Leave a Reply

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