Power Apps: Craft Dynamic Repeating Tables with Multiple Controls!
Power Apps
Jan 5, 2025 6:31 AM

Power Apps: Craft Dynamic Repeating Tables with Multiple Controls!

by HubSite 365 about Vipul Jain [MVP]

Consultant - M365, Power Platform, SharePoint, Azure, React JS | Speaker | Author | Trainer | C# Corner MVP

Citizen DeveloperPower AppsLearning Selection

Power Apps, Power Automate, Power Platform, Microsoft 365, SharePoint Online

Key insights

  • Repeating Table in Power Apps: Learn to create a repeating table where users can dynamically add or remove rows, each containing multiple controls like text boxes and dropdowns.

  • Data Storage in SharePoint: Save the data in JSON format within a SharePoint Online list. This is beneficial for scenarios such as entering line items on an invoice or collecting survey responses.

  • Initialize Collection: Add an "Add" icon to your app. Use the OnSelect property to initialize or add new rows with default blank values to a collection named PurchaseCollection.

  • Add Gallery Control: Insert a vertical gallery linked to PurchaseCollection. Add input controls for each field, ensuring numeric fields are set to "Number" format.

  • Calculate Derived Values: Set formulas in input controls to compute values like total price by multiplying quantity and price inputs.

  • Save Data to SharePoint: Use a "Save" button to patch collection data into the SharePoint list. A notification confirms successful submission of the order.

Introduction to Repeating Tables in Power Apps

Creating a dynamic and user-friendly interface is crucial for any application, and Power Apps provides a robust platform to achieve this. In a recent YouTube video by Vipul Jain, a Microsoft MVP, the process of creating a repeating table in Power Apps is explored. This feature allows users to dynamically add or remove rows, each containing multiple controls such as text boxes or dropdowns. Such functionality is particularly beneficial in scenarios like entering line items on an invoice or collecting survey responses. Let's delve into the steps and considerations involved in setting up a repeating table with multiple controls in Power Apps.

Setting Up Your Data Source

To begin with, it is essential to establish a reliable data source. In this case, a SharePoint Online list is used to store the repeating data. For example, you might create a list named "Purchase Order Details" with columns for Serial Number, Product Name, Product Quantity, Product Price, and Vendor Phone Number. This setup ensures that all data collected through the Power Apps interface is systematically stored and easily retrievable. However, selecting the right data source involves tradeoffs. While SharePoint Online offers seamless integration with Power Apps, it may not be suitable for applications requiring high-speed data processing or complex relational data structures. Therefore, assessing your specific needs and constraints is vital when choosing a data source.

Initializing a Collection in Power Apps

Once the data source is ready, the next step is to initialize a collection in Power Apps. This is achieved by adding an "Add" icon, represented by a "+" symbol, to your app. The OnSelect property of this icon is set to initialize or add a new row to a collection using Power Apps code. This code creates a new record in the PurchaseCollection with default blank values. Initializing a collection allows for temporary data storage within the app, facilitating real-time data manipulation before saving it to the SharePoint list. However, managing collections requires careful consideration of app performance and memory usage, especially when dealing with large datasets.

Adding a Gallery Control

The next phase involves adding a gallery control to display the repeating data. A blank vertical gallery is inserted, and its Items property is set to PurchaseCollection. Within the gallery, input controls corresponding to each field, such as text inputs for product name, quantity, and price, are added. The Default property of each input control is bound to the respective field in the collection. This setup ensures that any changes made by the user are immediately reflected in the collection. Additionally, setting the Format property for numeric fields to "Number" restricts input to numerical values, enhancing data integrity. However, designing an intuitive and responsive gallery layout can be challenging, especially when accommodating various screen sizes and orientations.

Calculating Derived Values and Row Management

In many applications, it is necessary to calculate derived values based on user inputs. For instance, the total price can be calculated by multiplying the quantity and price fields. This is done by setting the Default property of the corresponding control to a formula that computes the value. Furthermore, users must have the ability to remove rows from the repeating table. This is facilitated by adding a "Cancel" or "Delete" icon within the gallery item. The OnSelect property of this icon is set to remove the current item from the collection. While these features enhance user interactivity and data accuracy, implementing complex calculations and row management logic can increase the app's complexity and maintenance requirements.

Saving Data to SharePoint

After users have entered and reviewed their data, the final step is to save it to the SharePoint list. A "Save" button is added outside the gallery, and its OnSelect property is configured to save the collection data to the SharePoint list using a Power Apps code block. This code iterates through each item in the collection and patches it to the SharePoint list, ensuring that all user inputs are securely stored. Additionally, a notification is displayed to confirm successful data submission. While saving data to SharePoint is straightforward, it is crucial to handle potential errors and exceptions, such as network connectivity issues or data validation failures, to ensure a smooth user experience.

Conclusion

By following these steps, you can create a dynamic repeating table in Power Apps that allows users to add, edit, and remove multiple rows of data, with each row containing multiple input controls. This setup is particularly useful for forms requiring variable amounts of repeating data, such as purchase orders or surveys. However, balancing user interactivity, data integrity, and app performance requires careful planning and execution. For a visual demonstration and deeper understanding, Vipul Jain's video tutorial provides valuable insights into the practical implementation of these concepts in Power Apps.

Power Apps - Power Apps Mastery: Craft Dynamic Repeating Tables with Multiple Controls!

Keywords

Power Apps repeating table tutorial multiple controls guide create dynamic tables PowerApps part 1 how-to video.