Editing cells in a Dynamic Table
How cells in a Dynamic Table can be edited depends on whether they contain expressions or placeholders. Not sure what the difference is between expressions and placeholders? The difference is explained in another topic: Expressions or placeholders?
Note that even in a dynamic table where most of the cells contain expressions, cells can have a direct link to a data field. A cell that shows a subtotal always has a direct link to a data field.
Cells with expressions
Table cells with expressions can be edited in the following ways.
-
Additional text can be typed in a cell directly, before or after the expression. For example: Price: {{currency ItemPrice}}.
-
There is a number of Format Helpers that you can use in an expression to format the output differently.
-
To change the content or style of a cell or span, based on the value of a data field, you could write a "Helper", i.e. a function that can be used in an expression (see Creating custom Helpers).
-
You can add expressions to include data that is located somewhere else in the Data Model. Note that the expression will have to indicate where that data is relative to the table row (associated with a detail record) that contains the expression. . E.g. use ../ to navigate one level up. (See Accessing data at different levels.)
Cells with placeholders
Dynamic Table cells with a placeholder by default have a direct link to a data field.
To find out whether a cell or span has a direct link to a data field, select it and:
-
Take a look on the Attributes pane. If under Other, the Field drop-down or Sum field point to a data field in the detail table, the element has a direct link to a data field .
-
Switch to the Source view. Elements with a direct link to a data field have a data-field or data-sum attribute.
Cells with a direct link to a data field are edited as follows.
-
Which data field is linked to a cell and how the value is formatted can be changed via the Attributes pane.
-
Any text in the cell - including the placeholder - will be replaced with the value of the data field the cell is linked to, when the template is merged with data. To learn how to mix data and text in these cells, see Mixing text and data in a cell with a direct link to a data field.
Changing content based on a value
Changing the contents of a cell or row in a Dynamic Table, based on the value of a data field, requires a script. See Using scripts in Dynamic Tables.
Mixing text and data in a cell with a direct link to a data field
By default, each Dynamic Table cell that has a direct link to a data field shows a placeholder. For example: @CompanyName@ refers to a data field named CompanyName. However, these placeholders are not used as selector.
Instead, if a cell has the data-field or data-sum attribute, the software will replace the entire contents of that cell with a value: the current value of the data field, or a running total, respectively.
(For information about data- attributes see: HTML: table element and data- attributes).
Any text that was added in Design mode will disappear.
In order to mix data and text in a cell with a data- attribute, you should remove the data-field or data-sum attribute, respectively, from the cell itself and then put that attribute on an element inside the cell.
Here's how to do that.
-
In the Workspace, open the Design tab.
-
Select the cell (see Selecting an element).
-
On the Attributes pane, set Field or Sum to None.
-
Type text in the cell, before and/or after the placeholder.
-
Select the placeholder, right-click it and select Wrap in Span...
-
Select the new Span element.
-
On the Attributes pane, set Field or Sum to the desired data field.
-
Reapply the format if needed (see Formatting values).
Formatting values
Values in Dynamic Table cells can be formatted in different ways. A date value, for example, could be displayed as "Apr 2, 2016" (short date) or "4/2/16 12:00 AM" (medium date/time).
Which formats are possible depends on the data type of the field that contains the value (see Data types).
Selecting a format
The format of each value can be chosen when creating a table. For an explanation of the possible formats see Formatting variable data.
How you change the formatting of values in an existing table depends on whether the cell or span contains an expression or is directly linked to a data field (see Expressions or placeholders?).
If the cell or span contains an expression:
-
There is a number of Format Helpers that you can type in an expression to format the output differently.
If the cell or span has a direct link to a data field:
-
Select the element that contains the value and then use the Format drop-down on the Attributes pane.
- Open the Source tab and manually add the desired format to the cell using the
data-format
attribute (see A Dynamic Table's data- attributes).