getHtmlTable($table), $this->getDataTableOptions($table)); } /** * @param DataTableInterface $table * * @return array */ private function getDataTableOptions(DataTableInterface $table) { $options = $table->getOptions()->toArray(); $options['ajax'] = [ 'url' => $table->getConfig()->getAjaxUrl(), 'type' => $table->getConfig()->getAjaxMethod(), 'data' => $table->getConfig()->getAjaxParams(), ]; $options['columns'] = $table->getColumns()->toArray(); return $options; } /** * @param DataTableInterface $table * * @return string */ private function getHtmlTable(DataTableInterface $table) { $columns = $table->getColumns(); $headerHtml1 = ''; $footerHtml = ''; /** @var Column $column */ foreach ($columns as $column) { $headerHtml1 .= sprintf('%s', $column->getName(), $column->getTitle()); if ($column->has('footerHtml')) { $footerHtml .= sprintf('%s', $column->getName(), $column->get('footerHtml')); } else { $footerHtml .= sprintf('%s', $column->getName(), $column->getTitle()); } } $html = "\n"; $html .= sprintf( '', $table->getConfig()->getTableName(), $table->getConfig()->getCssClassesString(), $table->getConfig()->isAutoInit() ? 'true' : 'false' ) . "\n"; $html .= ''; $html .= '' . $headerHtml1 . ''; $html .= '' . "\n"; $html .= '' . $footerHtml . '' . "\n"; $html .= '
' . "\n"; return $html; } }