Beispiel #1
0
 /**
  *
  */
 public function actionDefault()
 {
     $news = $this->newsRepository->getAll()->where(['active' => 1])->orderBy(['dateAdd' => 'DESC']);
     $visualPaginator = $this['visualPaginator'];
     $paginator = $visualPaginator->getPaginator();
     $paginator->itemsPerPage = 5;
     $paginator->itemCount = $news->count();
     $news->limit($paginator->itemsPerPage);
     $news->offset($paginator->offset);
     $this->getTemplate()->news = $news->fetchAll();
     $this->getTemplate()->title = "Novinky";
     $this->getTemplate()->description = "Novinky";
     $this->getTemplate()->keywords = "Novinky";
 }
Beispiel #2
0
 /**
  * @param $name
  * @return Grid
  * @throws \Grido\Exception
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->newsRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('title', 'Titulek')->setSortable()->setFilterText();
     $grid->getColumn('title')->headerPrototype->style['width'] = '65%';
     $grid->addColumnDate('dateAdd', 'Datum')->setSortable()->setFilterText();
     $grid->addColumnText('active', 'Aktivní')->setCustomRender(function ($item) {
         if ($item->active === 0) {
             $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-down']);
             $el = Html::el('a', ['class' => 'btn btn-danger btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i);
         } else {
             $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-up']);
             $el = Html::el('a', ['class' => 'btn btn-success btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i);
         }
         return $el;
     })->cellPrototype->class[] = 'center';
     $grid->addActionEvent('delete', '')->setCustomRender(function ($item) {
         $i = Html::el('i', ['class' => 'fa fa-trash']);
         $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("delete!", $item->id))->setHtml($i);
         return $el;
     });
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->setDefaultSort(['dateAdd' => 'DESC']);
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }