public function render()
{
if (!$this->hasColumns()) {
throw new Exception('Grid must have defined a column, please use method $grid->addColumn*().');
}
$this->saveRememberState();
$data = $this->getData();
if (!empty($this->onRender)) {
$this->onRender($this);
}
$form = $this['form'];
$this->getTemplate()->add('data', $data);
$this->getTemplate()->add('form', $form);
$this->getTemplate()->add('paginator', $this->getPaginator());
$this->getTemplate()->add('customization', $this->getCustomization());
$this->getTemplate()->add('columns', $this->getComponent(Column::ID)->getComponents());
$this->getTemplate()->add('actions', $this->hasActions() ? $this->getComponent(Action::ID)->getComponents() : []);
$this->getTemplate()->add('buttons', $this->hasButtons() ? $this->getComponent(Button::ID)->getComponents() : []);
$this->getTemplate()->add('formFilters', $this->hasFilters() ? $form->getComponent(Filter::ID)->getComponents() : []);
$form['count']->setValue($this->getPerPage());
if ($options = $this->options[self::CLIENT_SIDE_OPTIONS]) {
$this->getTablePrototype()->setAttribute('data-' . self::CLIENT_SIDE_OPTIONS, json_encode($options));
}
$this->getTemplate()->render();
}