Exemple #1
0
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->model = $this->getData();
     $grid->filterRenderType = Filter::RENDER_OUTER;
     $grid->translator->lang = 'cs';
     $grid->defaultPerPage = 5;
     $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center';
     $header = $grid->getColumn('id')->headerPrototype;
     $header->rowspan = "2";
     $header->style['width'] = '0.1%';
     $grid->addColumnText('firstname', 'Jméno')->setSortable()->setFilterText()->setSuggestion();
     $grid->getColumn('firstname')->headerPrototype->style['width'] = '10%';
     $grid->addColumnText('surname', 'Příjmení')->setSortable()->setFilterText()->setSuggestion();
     $grid->getColumn('surname')->headerPrototype->style['width'] = '10%';
     $grid->addColumnNumber('allowance', 'Kapesné [CZK]', 2, ',', ' ')->setSortable()->setFilterNumber();
     $grid->getColumn('allowance')->cellPrototype->class[] = 'center';
     $grid->getColumn('allowance')->headerPrototype->class[] = 'center';
     $grid->getColumn('allowance')->headerPrototype->style['width'] = '6%';
     $grid->addFilterCustom('name', new \Nette\Forms\Controls\TextArea('Jméno nebo příjmení'))->setColumn('firstname')->setColumn('surname', \Grido\Components\Filters\Condition::OPERATOR_OR)->setCondition('LIKE ?')->setFormatValue('%%value%');
     $grid->addColumnDate('last_login', 'Poslední přihlášení')->setSortable()->setDateFormat(\Grido\Components\Columns\Date::FORMAT_DATETIME)->setReplacement(array(NULL => 'Nikdy'));
     $grid->getColumn('last_login')->cellPrototype->class[] = 'center';
     $grid->getColumn('last_login')->headerPrototype->class[] = 'center';
     $grid->getColumn('last_login')->headerPrototype->style['width'] = '9%';
     $grid->addColumnBoolean('ok', 'OK')->setSortable();
     $grid->addActionHref('edit', 'Upravit')->setIcon('pencil')->setCustomRender($this->gridHrefRender);
     $grid->addActionHref('delete', 'Smazat')->setIcon('trash')->setCustomRender($this->gridHrefRender)->setConfirm(function ($item) {
         return "Opravdu chcete smazat slečnu se jménem {$item['firstname']} {$item['surname']}?";
     });
     $grid->setExport();
 }