Introduction
Microsoft Power Apps offers an innovative way to create applications with ease. However, sometimes specific challenges arise that require unique solutions. Today, we’ll delve into how to dynamically set the height of nested galleries in Microsoft Power Apps for better aesthetics and user experience.
When handling related data in Power Apps, it’s common to display child records associated with a parent record using nested gallery controls. However, a recurring issue is the inconsistency in the height of these nested galleries. This often leads to unsightly gaps or scrollbars. So, let’s explore how to address this problem.
Demonstration of the Issue – Setting Up Nested Tables
Consider two tables for our example: One being a parent table storing property types, while the second is a table of properties. These tables are interlinked using a ‘PropertyTypeID’ value.
Fig1 - PropertyType Table
Fig2 - Property Table
To showcase the data, introduce a flexible height gallery (named galParent) on a screen, linking the Items property to the ‘PropertyTypes’ data source. Now, for the dynamic height adjustment to function effectively, the gallery should be of flexible height.
Additionally, for showcasing related child records, integrate a nested gallery named galChild. Associate its Items property with the formula:
Filter(Property, ThisItem.PropertyType_ID=PropertyTypeID)
As a result, running the app unveils the challenge. For instance, more records under the ‘house’ property type might trigger a nested scrollbar for that section. On the other hand, fewer records under ‘Apartment’ might result in undesired white space.
Adjusting Variable Height for Nested Gallery Controls
To amend this, it’s essential to determine the height of the nested gallery dynamically.
Here’s a solution: To decide the optimal height for every child gallery, multiply the target row number in the child gallery by the preferred height for each row. For instance, if each row should have a height of 35, set the galChild gallery’s height as:
CountRows(galChild.AllItems) * 35
Consequently, the outcome, illustrated in the succeeding screenshot, shows the nested gallery’s dynamic size, devoid of any unsolicited white spaces or scrollbars.
Conclusion
In conclusion, when it comes to showcasing interlinked parent-child data via nested galleries in Microsoft Power Apps, adjusting the nested galleries’ height dynamically is crucial. Thus, this guide aims to help you avoid unnecessary white spaces or scrollbars and achieve a cleaner, more professional look for your galleries.
If you find yourself needing further guidance or face any technical hurdles, don’t hesitate to contact us. We are here to assist, ensuring you get the most out of your Power Apps experience, and provide comprehensive technical support.