Filtering, sorting, and grouping directives help select and control how data appears in the generated document.
These directives can only be used with the
- <<rs_ repeating sections
- <<rr_ repeating rows
Filtering
The :filter()directive allows data to be shown only when a criteria is met.
The following template syntax:
<<rs_products:filter(type='Fruit')>>
<<name>>
<<es_products:filter(type='Fruit')>
is the same as:
FOR all products WHERE type is Fruit LOOP
OUTPUT name
END LOOP
Sorting
The :sort()directive allows data to be displayed in ascending or descending order.
The following template syntax:
<<rs_products:sort(name)>>
<<name>>
<<es_products:sort(name)>>
is the same as:
FOR all products SORTED by name LOOP
OUTPUT name
END LOOP
Note: By default the data is sorted in ascending order .To display the names in descending order, use:<<rs_products:sort(DESC,name)>>
Grouping
The :group()directive allows data to be grouped by a specific field or expression.
As soon as a :group() directive is encountered, the following two temporary variables are automatically created:
- $groupKey : holds the value of the field or expression used for grouping
- $groupItems : collects all items that share the group key value.
The Docmosis engine loops through each distinct $groupKey value and repopulates $groupItems for each new $groupkey, creating groups.
Note: $groupkey and $groupitems are available only within the repeating section or row where the grouping occurs.
The following template syntax:
<<rs_products:group(type)>>
<<$groupKey>>
<<rs_$groupItems>>;
<<name>>
<<es_$groupItems>>
<<es_products:group(type)>>
is the same as:
FOR all products GROUPED by type LOOP
OUTPUT type
FOR all products of that type LOOP
OUTPUT name
END LOOP
END LOOP