Some of the controls in the ForNAV Designer have a property named Can Grow (CanGrow). This feature can make controls change size to match the content. It is commonly used with the Text Box and Address controls where you normally don’t know the exact size of the content.
There are a few tricks you need to know to get the best results when using this feature.
The first thing that you have to know is that the control will grow in height, depending on how much space is available in the section where it is located. The growth in height and the location of the control is based on the Text Alignment property of the control. In most use cases, you should select Top Left for the Text Alignment property. This will most likely give you the result you are expecting.
A text box will grow in width to match the longest line in the content and it will grow in height to fit all lines or until it grows out of the section.
If you want to lock the width of a text box and only grow it in the vertical direction, then you must create a table and set the Can Grow property of the Cell, Row, and Table to yes. There is a trick to navigate from the Cell to the Row and Table: when you click a Cell, you can get the Row properties by pressing the Escape key. This technique will also take you from the Row to the Table properties. Alternatively, you can use the Report Explorer window to navigate between the elements.
You also have the possibility to make the section grow. When using this feature, the growing controls are not limited by the section height. The section itself will grow to fit the growing controls. Please note that only Body sections can grow.
The following shows a simple example of how to make the controls grow:
All the shown controls have a source expression with lines of numbers.
The controls on the left and in the middle are text boxes, and the one on the right is a table with a row and a cell. All the Can Grow properties are set to Yes.
The Text Alignment property is set to Top Left.
When the report is previewed, you can see that the text box grows in height and width whereas the table cell only grows is height.
Working with the Multiline property on the TextBox or TableCell controls can also affect how the control grows.
If you experience that the growing fields behave in a strange way where they overlap other controls, then your report might be running out of vertical space. You may also experience that text or HTML content is cut to fit on the page. Vertical space can be reserved by other sections following your growing section. The layout engine might not be able to determine which sections to reserve space for. We recommend reducing the number of headers or using a placeholder header followed by conditional headers with the watermark property set. Then, turn those watermark headers on and off using the show output expression.
When the size of the text is calculated on the service tier, it requires that the selected font is installed on the service tier. This is usually a problem when running a service tier on Docker and using the Role Tailored Client (RTC) for Business Central. Preview and print may show the right font but sometimes the text does not grow as expected. Our Docker article will show you how to install fonts on docker. Remember to restart your container after installing new fonts.
Can Grow and Can Shrink
It is not recommended that you enable the CanGrow and CanShrink properties simultaneously. This can lead to unexpected results.