EasyCatalog provides the ability to a create a matrix table — a table that expands both horizontally and vertically, populating data at the intersection of each column and row.
Matrix tables are defined using commands in an XML format, specified using the Script Label panel with the table selected.
There are three required nodes in the XML structure:
- <matrixtable> – this defines table-specified attributes such as the width of the table, how many columns should be fixed (header columns) at the left and right of the table, etc.
- <row> – defines the field that will be used to generate new rows in the table. A new row will be created in the document table per unique value specified by this node.
- <column> – defines the field that will be used to generate new columns in the table. A new column will be created in the document table per unique value specified by this node.
e.g.
1 2 3 4 | <matrixtable headercolumns="1"> <rows field="Width"/> <columns field="Height"/> </matrixtable> |
The behaviour of each of these nodes can be customised by adding additional attributes or sub-nodes:
<matrixtable> attributes
<rows> node attributes
<columns> node attributes
<group> node
By default, EasyCatalog will create one row or column per unique value in the specified fields on the <rows> and <columns> node. However, by adding the <group> node EasyCatalog will create a new row and column per unique value in the specified group.
1 2 3 4 5 6 | <matrixtable tablewidth="100%" headercolumns="1"> <rows field="part number"/> <columns field="colour"> <group field="finish"/> </columns> </matrixtable> |
In the above example, one column will be created per unique ‘colour’ per ‘finish’.
<range> node
The <range> node can be added to the <rows> and <column> node to restrict EasyCatalog to only populating the specified number of rows or columns. This is useful in situations where, for example, the resulting table could expand outside of the bounds of the page.
For example, in your Product Style you could include two tables with different <range> nodes: the first table could be set to…
1 2 3 | <columns field="myfield"> <range start="1" count="10"/> </columns> |
… and the second table set to:
1 2 3 | <columns field="myfield"> <range start="11" count="10"/> </columns> |
The first table would output columns for the first 10 records being used to populate the table; the second table would contain the next 10.
<filter> node
A single <filter> node can be added to the <row> and <column> nodes to exclude records from the table. This node will only include records in the table when the specified field matches the specified value.
1 2 3 | <rows field="myfield"> <filter field="include_in_matrix_table" value="true"/> </rows> |