diff options
Diffstat (limited to 'core/DataTable/Filter/GroupBy.php')
-rwxr-xr-x | core/DataTable/Filter/GroupBy.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/DataTable/Filter/GroupBy.php b/core/DataTable/Filter/GroupBy.php index b899bb9059..9391ccd95f 100755 --- a/core/DataTable/Filter/GroupBy.php +++ b/core/DataTable/Filter/GroupBy.php @@ -51,11 +51,11 @@ class GroupBy extends BaseFilter * @param DataTable $table The DataTable to filter. * @param string $groupByColumn The column name to reduce. * @param callable $reduceFunction The reduce function. This must alter the `$groupByColumn` - * columng in some way. + * columng in some way. If not set then the filter will group by the raw column value. * @param array $parameters deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php) * instead. */ - public function __construct($table, $groupByColumn, $reduceFunction, $parameters = array()) + public function __construct($table, $groupByColumn, $reduceFunction = null, $parameters = array()) { parent::__construct($table); @@ -80,10 +80,14 @@ class GroupBy extends BaseFilter continue; } - // reduce the group by column of this row $groupByColumnValue = $row->getColumn($this->groupByColumn); - $parameters = array_merge(array($groupByColumnValue), $this->parameters); - $groupByValue = call_user_func_array($this->reduceFunction, $parameters); + $groupByValue = $groupByColumnValue; + + // reduce the group by column of this row + if($this->reduceFunction) { + $parameters = array_merge(array($groupByColumnValue), $this->parameters); + $groupByValue = call_user_func_array($this->reduceFunction, $parameters); + } if (!isset($groupByRows[$groupByValue])) { // if we haven't encountered this group by value before, we mark this row as a |