/** * @param DataTable $value * @return array|Element[] */ public function headElements($value) { $elements = []; $table = $value->getTable(); $renderer = $this->renderers->getRenderer($table); if ($renderer instanceof WebRenderer) { $elements = $renderer->headElements($table); } $options = json_encode($value->getOptions()); $elements[] = HeadElements::style('//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css'); $elements[] = HeadElements::script('//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js'); $elements[] = new Element('script', [], ["\n \$(function () {\n \$('.data-table > table').dataTable({$options});\n });\n "]); return $elements; }
/** * @param DataTable $value * @return mixed */ public function render($value) { $table = $value->getTable(); return $this->renderers->getRenderer($table)->render($table); }