Piwik\DataTable\Filter\

GroupBy

DataTable filter that will group DataTable rows together based on the results of a reduce function.

Rows with the same reduce result will be summed and merged.

NOTE: This filter should never be queued, it must be applied directly on a DataTable.

Basic usage example

// group URLs by host
$dataTable->filter('GroupBy', array('label', function ($labelUrl) {
    return parse_url($labelUrl, PHP_URL_HOST);
}));

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):
    • $table (DataTable) — The DataTable to filter.
    • $groupByColumn (string) — The column name to reduce.
    • $reduceFunction (callable) — The reduce function. This must alter the $groupByColumn columng in some way. If not set then the filter will group by the raw column value.
    • $parameters (array) — deprecated - use an anonymous function instead.

filter()

See GroupBy.

Signature

  • It accepts the following parameter(s):

  • It does not return anything.

enableRecursive()

Enables/Disables recursive filtering.

Whether this property is actually used is up to the derived BaseFilter class.

Signature

  • It accepts the following parameter(s):

    • $enable (bool) —
  • It does not return anything.

filterSubTable()

Filters a row's subtable, if one exists and is loaded in memory.

Signature

  • It accepts the following parameter(s):
    • $row (Row) — The row whose subtable should be filter.
  • It does not return anything.