Skip to content

Latest commit

 

History

History
67 lines (47 loc) · 2.75 KB

group.rst

File metadata and controls

67 lines (47 loc) · 2.75 KB

Group changes

Compexity in applications usually grows exceptionlly with every addidtional group which needs to be managed.

With you only need to call the group() method once for every group. Groups can be controlled in every data dimension. Just call the group() method after calling the related data() method.

A group change occurs when within a data dimension when group values of the previous row don't equal those of the current row.

Tip

Data don't need to be sorted by groups. But make sure that rows are grouped by the group field or you might raise unwanted group changes.

Once a group change has been detected the appropiate action methods (group headers and group footers) will be executed.

Example

$rep = (new Report ($this))
->group ('region')
->group ('year', fn($row) => substr($row->saleDate, 0, 4))
->group ('month', fn($row) => substr($row->saleDate, 5, 2))
->group ('customer', 'customerID', null, '</table>')

The above example declares four groups (group level 1 to 4) to be monitored. Instead of executing the customer footer action the string '</table>' will be appended to the $output property.

Note

Group level 0 is always the top level which is called grandTotal.

For each declared group a group counter will be instantiated and incremented when a group change occurs. See 'Calculation' for details.