Exemple #1
0
 /** @return array|NULL */
 public function getFilterCriteria()
 {
     $this->validate();
     if ($this->isValid()) {
         return Helpers::filterEmpty($this['filters']['criteria']->getValues(TRUE));
     }
     return NULL;
 }
Exemple #2
0
 /** @return void */
 public function render()
 {
     $template = $this->createTemplate();
     $template->grid = $this;
     $template->defaultTemplate = __DIR__ . '/DataGrid.latte';
     $template->setFile($this->templateFile === NULL ? $template->defaultTemplate : $this->templateFile);
     $template->csrfToken = Helpers::getCsrfToken($this->session);
     $latte = $template->getLatte();
     $latte->addFilter('translate', [$this, 'translate']);
     $latte->addFilter('primaryToString', [$this->getRecord(), 'primaryToString']);
     $latte->addFilter('getValue', [$this->getRecord(), 'getValue']);
     $latte->addFilter('sortLink', function (Components\Column $c, $m = Helpers::SORT_LINK_SINGLE) {
         return Helpers::createSortLink($this, $c, $m);
     });
     if ($this->isControlInvalid()) {
         $this->redraw(FALSE, FALSE, ['flashes']);
     }
     $template->form = $form = $this['form'];
     $this->presenter->payload->twiGrid['forms'][$form->getElementPrototype()->id] = (string) $form->getAction();
     if ($this->presenter->isAjax()) {
         $latte->addProvider('formsStack', [$form]);
     }
     $template->columns = $this->getColumns();
     $template->dataLoader = [$this, 'getData'];
     $template->recordVariable = $this->recordVariable;
     $template->hasFilters = $this->filterFactory !== NULL;
     $template->rowActions = $this->getRowActions();
     $template->hasRowActions = $template->rowActions !== NULL;
     $template->groupActions = $this->getGroupActions();
     $template->hasGroupActions = $template->groupActions !== NULL;
     $template->hasInlineEdit = $this->ieContainerFactory !== NULL;
     $template->iePrimary = $this->iePrimary;
     $template->isPaginated = $this->itemsPerPage !== NULL;
     $template->columnCount = count($template->columns) + ($template->hasGroupActions ? 1 : 0) + ($template->hasFilters || $template->hasRowActions || $template->hasInlineEdit ? 1 : 0);
     $template->render();
 }