The groupList header allows a sequence to be ordered by creating virtual groups. By placing this macro in the groupList content, it is possible, when browsing the ordered sequence, to detect when the current element is the first element in a group, in order to execute the nested content of this macro.
This macro can be used to display information on the current group (its title for example) before displaying the content of the current element.
When browsing the ordered sequence, the nested content of this macro will only be executed once per group: when the current element is the first in the group.
For example
<#assign seqData = [{"name": "mary", "age": 18}, {"name": "Lucy", "age": 19}, {"name": "Mark", "age": 19}, {"name": "Charlie", "age": 17}, {"name": "Aaron", "age": 18}, {"name": "Tess", "age": 16}, {"name": "Isaac", "age": 16} ]/> <#assign orderingCriteria = {"name": "original_order_by_age", "colName": "age", "order":"o"} /> <@hardisAdv.groupList .data_model.seqData orderingCriteria; aPerson> <@hardisAdv.groupHeader "original_order_by_age"> Here is a new age group: </@hardisAdv.groupHeader> ${ aPerson.name} has ${ aPerson.age } </@hardisAdv.groupList>
has the result:
Here is a new age group:
Mary is 18
Here is a new age group:
Lucy is 19
Mark is 19
Here is a new age group:
Charlie is 17
Here is a new age group:
Aaron is 18
Here is a new age group:
Tess is 16
Isaac is 16
Information can be accessed from the current element group by passing a loop variable to the macro which will be supplied by it and can be used in its nested content. This variable is a Hash object which groups information on the group via the following attributes:
- label: group title,
- startRow: number of row in the ordered sequence of the first element of the group,
- endRow : number of row in the ordered sequence of the last element of the group,
- namedGroup: name of the named group if the current element group is a named group.
For example
<#assign seqData = [{"name": "mary", "age": 18}, {"name": "Lucy", "age": 19}, {"name": "Mark", "age": 19}, {"name": "Charlie", "age": 17}, {"name": "Aaron", "age": 18}, {"name": "Tess", "age": 16}, {"name": "Isaac", "age": 16} ]/> <#assign orderingCriteria = {"name": "original_order_by_age", "colName": "age", "order":"o"} /> <@hardisAdv.groupList .data_model.seqData orderingCriteria; aPerson> <@hardisAdv.groupHeader "original_order_by_age"; infoGroupOriginalOrderByAge> Group of ${ infoGroupOriginalOrderByAge .label}: ${ infoGroupOriginalOrderByAge .endRow - infoGroupOriginalOrderByAge .startRow } people </@hardisAdv.groupHeader> ${ aPerson.name} has ${ aPerson.age } </@hardisAdv.groupList>
has the result:
Group of 18: 1 people
Mary is 18
Group of 19: 2 people
Lucy is 19
Mark is 19
Group of 17: 1 people
Charlie is 17
Group of 18: 1 people
Aaron is 18
Group of 16: 2 people
Tess is 16
Isaac is 16
Empty directive: No
Parameters
String |
groupName |
Name of the group whose input is to be detected during browsing |
Mandatory |
For example
<@hardisAdv.groupList .data_model.seqItems orderingCriteria; aItem> <@hardisAdv.groupHeader "orderGroup1"; infoGroup> Beginning of group ${ infoGroup.label } </@hardisAdv.groupHeader> ... ${ aItem.fooAttribute} ... <@hardisAdv.groupFooter "orderGroup1"; infoGroup> End of group ${ infoGroup.label } </@hardisAdv.groupFooter> </@hardisAdv.groupList>