Repeating Elements¶
In CxReports, you can set up visual elements to repeat based on data arrays. This is handy for displaying lists of items dynamically.
To enable repeating for an element, go to the Repeat
section in the element's configuration and switch on the Repeat this component
option.
Next, choose an array data source for the element. The element will repeat for each item in the array. Keep in mind that repeating elements are only visible in preview mode. While editing, only one item will be shown.
To access the data within the repeating elements, you need to specify a data alias. By default, this alias is record
, but you can change it to something more meaningful.
For example, let's say we have the following data source:
We can set up a Text element to repeat for each item in this list. To do this, we will create an alias called person
.
- In the
Repeat
section, set the data alias toperson
. - Use this alias within the text component to reference the data.
For instance, the text template within the text component would use the $it.person
alias. You could write:
Think of $it
as a shorthand for "item" or "iterator."
Besides text, you can use the same approach for other elements such as images, bar codes, QR codes, and other components commonly used to display dynamic data.
By following these steps, you can make your reports more dynamic and data-driven by repeating elements based on your data arrays.