setDefaultPerPage() public method

Sets the default number of items per page.
public setDefaultPerPage ( integer $perPage ) : Grid
$perPage integer
return Grid
Example #1
0
 /**
  * @param $name
  * @return Grid
  * @throws \Grido\Exception
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->searchRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('term', 'Hledaný termín')->setSortable()->setFilterText();
     $grid->getColumn('term')->headerPrototype->style['width'] = '75%';
     $grid->addColumnNumber('count', 'Počet hledání')->setSortable();
     $grid->getColumn('term')->headerPrototype->style['width'] = '25%';
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #2
0
 /**
  * @param $name
  * @return Grid
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->sliderRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('imgName', 'Obrázek')->setCustomRender(function ($item) {
         $img = Html::el('img')->src($item->imgName)->width('200');
         return $img;
     });
     $grid->addColumnText('imgTitle', 'Titulek')->setSortable()->setFilterText();
     $grid->getColumn('imgTitle')->headerPrototype->style['width'] = '20%';
     $grid->addColumnText('imgDescription', 'Popisek')->setSortable()->setFilterText();
     $grid->getColumn('imgDescription')->headerPrototype->style['width'] = '40%';
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $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->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #3
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;
 }
Example #4
0
 public function createComponentWebProfilesPermitGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->userService->getWebProfilesToPermitDatasource());
     $grid->setTranslator($this->getTranslator());
     $grid->setDefaultPerPage(30);
     $grid->setPrimaryKey('id');
     $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center';
     $headerId = $grid->getColumn('id')->headerPrototype;
     $headerId->class[] = 'center';
     $headerId->rowspan = "2";
     $headerId->style['width'] = '0.1%';
     $grid->addColumnText("personalLikes", "usersModule.admin.wpGrid.content.label")->setTruncate(100)->setCustomRender($this->wpDataRender)->cellPrototype->class[] = 'center';
     $headerData = $grid->getColumn('personalLikes')->headerPrototype;
     $headerData->class[] = 'center';
     $headerData->style['width'] = '70%';
     $grid->addColumnText("personalDisLikes", "usersModule.admin.wpGrid.photo.label")->setCustomRender($this->wpPhotoRender)->cellPrototype->class[] = 'center';
     $headerPhoto = $grid->getColumn('personalDisLikes')->headerPrototype;
     $headerPhoto->class[] = 'center';
     $headerPhoto->style['width'] = '8%';
     $y = $this->tt("system.common.yes");
     $n = $this->tt("system.common.no");
     $activeList = [null => null] + [true => $y, false => $n];
     $grid->addColumnText('publish', $this->tt("systemModule.admin.grid.active"))->setSortable()->setReplacement([true => $y, null => $n])->setFilterSelect($activeList);
     $headerAct = $grid->getColumn('publish')->headerPrototype;
     $headerAct->class[] = 'center';
     $headerAct->style['width'] = '0.1%';
     $grid->addActionHref('yes', '', "permitProfile!")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("usersModule.admin.grid.permitProfile")]))->setIcon('ok')->setConfirm(function ($u) {
         return $this->tt("usersModule.admin.wpGrid.reallyPermitItem", null, ["id" => $u->getId()]);
     });
     $grid->addActionHref('no', '', "denyProfile!")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("usersModule.admin.grid.denyProfile")]))->setIcon('remove')->setConfirm(function ($u) {
         return $this->tt("usersModule.admin.wpGrid.reallyDenyItem", null, ["id" => $u->getId()]);
     });
     $operation = array('yes' => 'Permit', 'no' => 'Deny');
     $grid->setOperation($operation, $this->wppGridOperationsHandler)->setConfirm("yes", $this->tt("usersModule.admin.wpGrid.reallyPermitItems"))->setConfirm("no", $this->tt("usersModule.admin.wpGrid.reallyDenyItems"));
     $grid->setFilterRenderType($this->filterRenderType);
     $grid->setExport("admin-users " . date("Y-m-d H:i:s", time()));
     return $grid;
 }
Example #5
0
 /**
  * Create grid UI component Grido\Grid
  *
  * @param array|IRepository|Selection $data
  * @param string                      $primaryKey
  * @param integer                     $perPage
  * @param array                       $permanentlyFilter
  *
  * @return Grid
  */
 public function createGrido($data = null, $primaryKey = null, $perPage = null, $permanentlyFilter = [])
 {
     $grid = new Grid();
     // set data model
     if ($data) {
         if ($data instanceof IRepository) {
             $dataModel = new Mepatek\Components\Grido\DataSources\RepositorySource($data);
             $dataModel->setPermanentlyFilter($permanentlyFilter);
         } elseif ($data instanceof Selection) {
             $dataModel = new Grido\DataSources\NetteDatabase($data);
         } else {
             $dataModel = new Grido\DataSources\ArraySource($data);
         }
         $grid->setModel($dataModel);
     } else {
         $dataModel = new Grido\DataSources\ArraySource([]);
         $grid->setModel($dataModel);
     }
     // set primary key
     if ($primaryKey) {
         $grid->setPrimaryKey($primaryKey);
     }
     // set properties of grido
     $grid->filterRenderType = \Grido\Components\Filters\Filter::RENDER_INNER;
     if ($this->translator) {
         $grid->setTranslator($this->translator);
     }
     $grid->getTablePrototype()->class("table table-striped table-hover table-bordered dataTable");
     // set item per page
     if ($perPage) {
         $grid->setDefaultPerPage($perPage);
     }
     return $grid;
 }
Example #6
0
 /**
  * @param $name
  * @return Grid
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->pagesRepository->getAll();
     $pages = [];
     foreach ($fluent as $pageRow) {
         $pages[$pageRow->id] = $pageRow;
     }
     if (isset($grid->model)) {
         $grid->model = $fluent;
     }
     $grid->addColumnNumber('id', 'ID');
     $header = $grid->getColumn('id')->headerPrototype;
     $header->style['width'] = '0.5%';
     $grid->addColumnText('name', 'Název')->setFilterText()->setSuggestion();
     $grid->getColumn('name')->headerPrototype->style['width'] = '80%';
     $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->addColumnText('inMenu', 'Top menu')->setCustomRender(function ($item) {
         $menuItems = (array) json_decode($item->inMenu);
         if (!in_array('topMenu', $menuItems)) {
             $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("inTopMenu!", $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("inTopMenu!", $item->id))->setHtml($i);
         }
         return $el;
     })->cellPrototype->class[] = 'center';
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->addActionEvent('delete', '')->setCustomRender(function ($item) {
         if ($item->parent === 0 || $item->rgt - $item->lft > 1) {
             $i = Html::el('i', ['class' => 'fa']);
             $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i);
         } else {
             $i = Html::el('i', ['class' => 'fa fa-trash']);
             $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax', 'data-grido-confirm' => "Opravdu chcete tuto položku odstranit?"])->href($this->presenter->link("delete!", $item->id))->setHtml($i);
         }
         return $el;
     });
     $grid->addActionEvent('moveup', '')->setCustomRender(function ($item) use($pages) {
         $first = $item->parent == 0 || $item->lft - 1 == $pages[$item->parent]['lft'];
         if ($first) {
             $i = Html::el('i', ['class' => 'fa']);
             $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i);
         } else {
             $i = Html::el('i', ['class' => 'fa fa-arrow-up']);
             $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("move!", $item->id, self::UP))->setHtml($i);
         }
         return $el;
     });
     $grid->addActionEvent('movedn', '')->setCustomRender(function ($item) use($pages) {
         $last = $item->parent == 0 || $item->rgt + 1 == $pages[$item->parent]['rgt'];
         if ($last) {
             $i = Html::el('i', ['class' => 'fa']);
             $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i);
         } else {
             $i = Html::el('i', ['class' => 'fa fa-arrow-down']);
             $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("move!", $item->id, self::DN))->setHtml($i);
         }
         return $el;
     });
     $grid->addActionHref('add', '')->setIcon('plus');
     $grid->setDefaultSort(['lft' => 'ASC']);
     $grid->setRememberState(TRUE);
     $grid->setPrimaryKey('id');
     $grid->setDefaultPerPage(50);
     $grid->setRowCallback(function ($item, $tr) {
         $tr->class[] = "level_{$item->level}";
         return $tr;
     });
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #7
0
 /**
  * @param $name
  * @return Grid
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->usersRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('username', 'Username')->setSortable()->setFilterText();
     $grid->addColumnText('name', 'Name')->setSortable()->setFilterText();
     $grid->addColumnText('lastname', 'Lastname')->setSortable()->setFilterText();
     $grid->addColumnText('role', 'Role')->setSortable()->setFilterText();
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->addActionEvent('delete', '')->setCustomRender(function ($item) {
         $i = \Nette\Utils\Html::el('i', ['class' => 'fa fa-trash']);
         $el = \Nette\Utils\Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("delete!", $item->id))->setHtml($i);
         return $el;
     });
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #8
0
 /**
  * @param $name
  * @return Grid
  * @throws \Grido\Exception
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->commentsRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('author', 'Autor')->setSortable()->setFilterText();
     $grid->addColumnDate('date', 'Datum')->setSortable()->setFilterText();
     $grid->addColumnText('allowed', 'Schváleno')->setCustomRender(function ($item) {
         if ($item['allowed'] === 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("allowed!", $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("allowed!", $item['id']))->setHtml($i);
         }
         return $el;
     })->cellPrototype->class[] = 'center';
     $grid->addColumnText('text', 'Text')->setCustomRender(function ($item) {
         $el = Html::el('span')->setText(Strings::substring($item['text'], 0, 80));
         return $el;
     });
     $grid->getColumn('text')->headerPrototype->style['width'] = '90%';
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $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->setDefaultSort(['date' => 'DESC']);
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #9
0
 /**
  * @param $name
  * @return Grid
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->articlesRepository->getAll();
     $articles = [];
     foreach ($fluent as $articleRow) {
         $articles[$articleRow->id] = $articleRow;
     }
     if (isset($grid->model)) {
         $grid->model = $fluent;
     }
     $grid->addColumnNumber('id', 'ID');
     $header = $grid->getColumn('id')->headerPrototype;
     $header->style['width'] = '0.5%';
     $grid->addColumnText('name', 'Název')->setFilterText()->setSuggestion();
     $grid->getColumn('name')->headerPrototype->style['width'] = '40%';
     $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->addActionHref('edit', '')->setIcon('pencil');
     $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', 'data-grido-confirm' => "Opravdu chcete tuto položku odstranit?"])->href($this->presenter->link("delete!", $item->id))->setHtml($i);
         return $el;
     });
     $grid->setDefaultSort(['date' => 'DESC']);
     $grid->setRememberState(true);
     $grid->setPrimaryKey('id');
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
Example #10
0
 /**
  * @param $name
  * @return Grid
  * @throws \Grido\Exception
  */
 protected function createComponentGridPictures($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->picturesRepository->getAllWhere(['galleryId' => $this->getParameter('id')]);
     $grid->model = $fluent;
     $grid->addColumnText('id', 'ID')->setSortable();
     $grid->getColumn('id')->headerPrototype->style['width'] = '1%';
     $grid->addColumnText('name', 'Název')->setSortable()->setFilterText();
     $grid->getColumn('name')->headerPrototype->style['width'] = '25%';
     $grid->addColumnText('file', 'Soubor')->setSortable()->setFilterText();
     $grid->getColumn('file')->headerPrototype->style['width'] = '40%';
     $grid->addActionHref('editPicture', '')->setIcon('pencil');
     $grid->addActionEvent('deletePicture', '')->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("deletePicture!", $item->id))->setHtml($i);
         return $el;
     });
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }