Customizing a Dynamic Table
Once a Dynamic Table been added to a template, it isn't possible to open it in the Wizard again. But you can still add header and footer rows that appear at the start or end of the table or at the top or bottom of every page. You can also add subtotals, and you can hide the table or a table row when it's empty.
Tip: When you add a new Dynamic Table, the Wizard will open with the last used settings.
Adding a header or footer row
A Dynamic Table that is created by the Wizard always has a header (a <thead> element). It will also have a footer (a <tfoot> element) if you chose to add Subtotals when you created the table.
Sometimes you may want to add more rows to the header or footer of a Dynamic Table, for example, to add taxes and/or the total of an invoice, or to add a custom message like 'Continued on next page'.
A header or footer row can be added to a Dynamic Table as follows.
-
In the workspace, open the Design tab.
-
If the table already has a header/footer:
-
Right-click the header of the table if you want to add a header row, or the footer of the table if you want to add a footer row.
-
On the shortcut menu select Row > Insert below or Insert above. The new row will be added to the header or footer.
If the table doesn't have a header/footer, add it (see Adding a header or footer) and proceed with the next step.
Tip: To determine if a table has a header and/or footer, expand the table on the Outline pane.
-
-
Select the new row (see Selecting an element).
-
On the Attributes pane, select one of the options from the Show Row drop-down that specifies whether the row must be repeated in the output. The options are:
-
At start of table: The row will only appear on the page where the table starts.
-
All: The row will appear on all pages.
-
Before page break: The row will appear on all pages except the last.
-
After page break: The row will appear on all pages except the first.
-
At end of table: The row will only appear on the last page.
-
You can fill the new header or footer rows as usual. You could for example drag a root level data field to the row (see Variable data in the text) or type in the cells.
You could add a subtotal (see Adding subtotals).
You could also add a script, or a script and text (see Mixing text and data in a cell with a direct link to a data field).
Adding subtotals
When creating a Dynamic Table with the Wizard, you can add subtotals based on one data field to the table's footer and header. It is also possible to add (extra) subtotals to an existing Dynamic Table.
Subtotals are added by using the data-sum and data-show-row attributes, normally in the header and/or footer of the table.
Note that this requires the table to have the data-expander="2019" attribute. (This is visible in the HTML. Switch to Source view and look at the <table> element.) Tables created with the Dynamic Table Wizard that was introduced in version 2020.1 will get this attribute automatically. The same goes for a standard table that has been turned into a Dynamic Table.
For information about a Dynamic Table's attributes see A Dynamic Table's data- attributes.
To add subtotals to the header and/or footer:
-
In the workspace, open the Design tab.
-
If the table doesn't have a header/footer, add it (see Adding a header or footer). To determine if a table has a header and/or footer, expand the table on the Outline pane.
-
If you need an extra row in the header or footer:
-
Right-click the header or the footer of the table, depending on where you want to add a row.
-
On the shortcut menu, select Row > Insert below or Insert above.
-
-
Specify on which pages the row must appear in the output:
-
Select the row to which you want to add a subtotal (see Selecting an element).
- On the Attributes pane, select one of the options from the Show Row drop-down:
All: The row will appear on all pages.
Before page break (footer rows only): The row will appear on all pages except the last.
After page break (header rows only): The row will appear on all pages except the first.
At end of table: The row will only appear on the last page.
-
-
Now, add the subtotal to a cell in that row. This procedure is the same for subtotals in the header and footer.
-
Select the cell (see Selecting an element).
-
Select the data field:
-
On the Attributes pane, from the Sum drop-down, select the data field on which the subtotal must be based. The drop-down will offer all eligible fields, including those in nested detail tables.
-
Alternatively, e.g. to select a data field in a nested detail table, switch to Source view and manually add the data-sum attribute to the table cell (the <td> element).
Its value should consist of the path to the data field. For example: <td data-sum="Instruments.Items.Amount">. This cell will have a subtotal based on the "Amount" field in the "Items" detail table which is nested in the "Instruments" detail table.
-
-
You could also add text like "continued on next page" or "continued from previous page" to the cell. See Editing cells in a Dynamic Table.
-
Subtotals inside a Dynamic Table
Subtotals normally appear in the header or footer of a table; however, it is also possible to insert subtotals in cells in the body of a table.
- Start by adding a row to the body of the table: right-click a row in the table, depending on where you want to add a row, and select Row > Insert below or Insert above.
If the row should occur only once, you can now proceed with step 5 in Adding a header or footer row.
If the row should occur as often as a certain detail table, it must be associated with that detail table first.
-
Select the row (see Selecting an element).
-
Change the row's Repeat attribute on the Attribute pane from None to the desired detail table. Usually this will be the detail table that is one level higher than the one that contains the field for which the subtotal must be calculated.
-
Proceed with step 5 in Adding a header or footer row. The Sum drop-down will now only show the names of fields that occur in the specified detail table and in its nested detail tables.
Hiding an empty Dynamic Table
The number of rows in a Dynamic Table is variable, as it depends on a detail table in the data.
You can hide a table that does not contain any data. There are two ways to achieve that.
-
When creating a Dynamic Table, you can check the option Hide when empty. (See Creating a Dynamic Table.)
-
For an existing Dynamic Table you can select the table (see Selecting an element) and check the option Hide when empty on the Attributes pane.
Hiding an empty table row
Empty rows are omitted from a Dynamic Table by default.
A row is considered empty if all elements with a data-field attribute in that row refer to empty data fields. Any additional text is not taken into account.
To keep empty rows visible in the output:
-
Switch to Source view.
-
Add the
data-keep-when-empty
attribute to the respective <tr> element(s).Example:
<tr data-repeat="Instruments" data-keep-when-empty="">
.Tip: To locate a row you can select it on the Outline pane.