groupColumns = $columnNames; $this->enabled = true; } /** * @param DataTableInterface $table * * @throws ColumnNotFoundException * * @return void */ public function modifyTable(DataTableInterface $table) { foreach ($this->groupColumns as $columnName) { if (!$table->getColumns()->has($columnName)) { throw new ColumnNotFoundException(sprintf( 'RowGroupFeature failed. Column "%s" not found.', $columnName )); } } if ($this->enabled === true) { $table->getOptions()->setOption('rowGroup', ['dataSrc' => $this->groupColumns]); } if ($this->enabled === false) { $table->getOptions()->setOption('rowGroup', false); } } /** * @param array $columnNames * * @return void */ public function groupBy(array $columnNames) { if (count($columnNames) === 0) { throw new InvalidArgumentException('Parameter "columnNames" is can not be empty.'); } $this->groupColumns = $columnNames; } /** * @return void */ public function enable() { $this->enabled = true; } /** * @return void */ public function disable() { $this->enabled = false; } }