protected function createComponentGrid($name) { $dataSource = $this->entityModel->reflection("datasource"); $dibiSource = $dataSource->setTable("content")->table(NULL); $grid = new \Natsu\Control\GridControl(); $grid->setName($name); $grid->setPk('id'); $grid->setDibiSource($dibiSource); $grid->setColumns(array('id' => 'ID', 'sectionId' => 'Sekce', 'title' => 'Title', 'isNews' => 'Novinka')); $grid->setCallBack(array('type' => function ($item) { if ($item->isDraft) { return "Draft"; } else { if ($item->isNews) { return "Novinka"; } else { return "Stránka"; } } })); $grid->setButtons(array('form' => 'Form', 'view' => 'View')); $grid->run(); return $grid->getGrid(); }
protected function createComponentPagesList($name) { if (!($this->user->loggedIn && ($this->user->identity->roleId == 1 || $this->user->identity->roleId == 2))) { throw new \Nette\Application\ForbiddenRequestException(); } $dataSource = $this->entityModel->reflection("datasource"); $dibiSource = $dataSource->setTable("content")->table(NULL); $grid = new \Natsu\Control\GridControl(); $grid->setName($name); $grid->setPk('id'); $grid->setPresenter("Content"); $grid->setDibiSource($dibiSource); $grid->setColumns(array('id' => 'ID', 'sectionId' => 'Sekce', 'title' => 'Title', 'isNews' => 'Novinka')); $grid->setCallBack(array('type' => function ($item) { if ($item->isDraft) { return "Draft"; } else { if ($item->isNews) { return "Novinka"; } else { return "Stránka"; } } })); $grid->setButtons(array('form' => 'Form', 'view' => 'View')); $grid->run(); return $grid->getGrid(); }