GroupTemplating System : Designer Guide : Tag Reference : Group
The group tag is used only within the body of a multiple tag to provide additional formatting control between subsets of a multirow data source. The tag takes a column name from the enclosing multiple tag as its only attribute. It repeats a template section as long as the value of the column does not change from row to row.
The group tag also sets two additional values in your multirow:
- groupnum is the rownum within the innermost group tag, starting from 1, 2, 3, etc.
- groupnum_last_p is a boolean saying whether this is the last row inside the current group tag, before the value of column changes. Note, however, that this only works inside the inner-mostgroup if you have multiple group tags nested within each other.
<table> <multiple name="shirts"> <!-- Start a new row if the style changes --> <tr> <td> @shirts.style@ </td> <td> <!-- List colors for the same style in a single cell --> <group column="style"> @shirts.color@ <!-- @shirts.groupnum@ will be the number of the color within the style --> <if @shirts.groupnum_last_p@ false>, </if> <else>, or </if> </group> <!-- End the row if the style is going to change on the next row </td> </tr> </multiple> </table>
[Note: Carsten added this feature during the Berlin Hackaton 2004-02-14]
The delimiter attribute will add a string after each row except the last row in the group:
<group delimiter=" | "> ...
This attribute will cause the rows within the group to appear to be sepparated by vertical bars. This is much more convenient than using the <groupnum_last_p> tags to check whether we are on the last row.
Group tags may be nested to perform even more complex formatting.
Be careful when nesting several group tags. The group tag works very narrowly - it only looks at the column you provide it with and so long as that column doesn't change, it keeps looping. E.g. if you have 3 levels and the value of the outermost column changes but the value of the middle column doesn't, the inner group tag won't notice and will continue to loop. A workaround would be to create a derived column, which contains e.g. "$f1,$f2", and use that as the column for the inner group tag. (See also this bug).