ColumnCallbackAddColumn
Piwik\DataTable\Filter\
ColumnCallbackAddColumn
Adds a new column to every row of a DataTable based on the result of callback.
Basic usage example
$callback = function ($visits, $timeSpent) {
return round($timeSpent / $visits, 2);
};
$dataTable->filter('ColumnCallbackAddColumn', array(array('nb_visits', 'sum_time_spent'), 'avg_time_on_site', $callback));
Methods
The class defines the following methods:
__construct()— Constructor.filter()ash; See ColumnCallbackAddColumn.enableRecursive()ash; Enables/Disables recursive filtering. Inherited fromBaseFilterfilterSubTable()ash; Filters a row's subtable, if one exists and is loaded in memory. Inherited fromBaseFilter
__construct()
Constructor.
Signature
It accepts the following parameter(s):
$table(DataTable) —$columns(array|string) — The names of the columns to pass to the callback.$columnToAdd(string) — The name of the column to add.$functionToApply(callable) — The callback to apply to each row of a DataTable. The columns specified in$columnsare passed to this callback.$functionParameters(array) — deprecated - use an anonymous function instead.
filter()
Signature
It accepts the following parameter(s):
$table(DataTable) —
It does not return anything or a mixed result.
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 or a mixed result.
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 or a mixed result.