table
A Word content command that iterates through all items of a Collection and produces a copy of all of a table's pre-existing non-header rows, contents included, for every item in the Collection. Any Word content commands in content controls within the rows or around them are also copied and evaluated on each round of the iteration, with one of the items of the Collection as a variable in the context for these commands to make use of. This command should be placed into a content control around a table.
If the table contains header rows, those rows are not multiplied during the iteration, but any Word content commands within these rows are evaluated before the iteration process occurs. If the footerRows
attribute is used to define footer rows, these are treated in the same way, except that the evaluation of their content commands occurs after the iteration process.
This command produces a local variable context for the Word content commands evaluated within the iteration rounds. This local context's primary feature is that it contains one of the Collection's items for the other content commands to access. A new context is created at the start of every round of the iteration process and then terminated at the end of the round.
This attribute has a priority of 90.
Syntax:
table(value,var,varStatus,footerRows,roundTest)
With required attributes only:
table(value,var)
Attributes
#1 - value | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | Collection, Map, Data Item | Yes |
This attribute defines the container whose contents the command will iterate through. While this container is primarily expected to be a Collection, two other types of values are also accepted. The three types are handled in the following ways:
If the value is either an empty Collection or an empty Map, the entire table will be removed. |
#2 - var | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | No |
The value of this attribute defines the name of the local context variable that holds the current item of the loop. |
#3 - varStatus | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | No |
Defines the name of the variable that holds a Loop Status value. Loop Status has the properties Property |
#4 - footerRows | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Number, String | Yes |
Defines the number of rows in the original table within the host content control that are treated as footer rows. A footer row is treated the same as a header row - it will not be multiplied during the iteration, but any content commands within the row are evaluated. The resolved value, which may be a Number or a String with a number character, defines how many rows, counted from the bottom, become footer rows. If undefined, no rows are treated as footer rows. |
#5 - roundTest | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
This attribute can be used to define a condition for skipping certain iteration rounds. This attribute's expression is evaluated at the start of every round and if it doesn't resolve into If undefined, no iteration rounds are skipped. |
Examples
The table
command works in a very similar manner to repeat, but is specialized in tables with its header and footer row features. This command also allows multiple rows per iteration round to be multiplied, as a single content control cannot be wrapped around multiple table rows and therefore cannot be multiplied like that with repeat
. The following example could be used to create a table of products, with one footer row.
table(products,product,,1)
While the table
is intended to be the replacement of repeat
for tables, these two can also be used together to produce a group of dynamic tables based on the repeat
's Collection, as repeat
has higher priority than the table
. The following uses repeat
to produce a separate product table for every product group.
repeat(productGroups,group) table(group.products,product,,1)
Use the fifth attribute roundTest
to skip over iteration rounds. Note that it is possible to use the Loop Status value created through the third attribute varStatus
or the current item of the iteration in roundTest
's expression. The following example would produce the product table, but without any products that have not been released yet.
table(products,product,status,1,product.releaseDate != null)