Exemplo n.º 1
0
 protected function createComponentInterpretList($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->interpreti->findAll());
     $grid->addColumnText("nazev", "Interpret")->setCustomRender(function ($item) {
         return !$item->interpret_id ? Html::el('b')->setText($item->nazev) : $item->nazev;
     })->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText("alias", "Alias pro")->setColumn(function ($item) {
         return isset($item->interpret->nazev) ? $item->interpret->nazev : null;
     });
     $grid->addFilterCheck('interpret_id', 'Jen aliasy');
     $grid->addColumnText("desc", "Popis")->setCustomRender(function ($item) {
         return Strings::truncate($item->desc, 256);
     });
     $grid->addActionHref('edit', 'Editovat', 'editor')->setIcon('pencil');
     $grid->addActionHref('delete', 'Smazat', 'delete!')->setIcon('trash')->setConfirm('Opravdu chcete smazat tohoto interpreta?');
     //Set face for grid
     $gridTemplate = __DIR__ . "/../templates/components/Grid.latte";
     if (file_exists($gridTemplate)) {
         $grid->setTemplateFile($gridTemplate);
     }
     return $grid;
 }