public function createComponentGridRoles($name) { $persister = new \Gridder\Persisters\SessionPersister($this->getSession('grid-permissions')); $repository = $this->em->getRepository('UserRole'); $source = new \Gridder\Sources\RepositorySource($repository); $grid = new \Gridder\Gridder($source, $persister, $this, $name); $grid->addColumn('name'); $grid->addColumn('permissions', 'entityChild')->setPath('permissions'); $ac = $grid->addActionColumn('actions'); $ac->addAction('edit', 'edit!', true)->setIcon('normal edit')->hideTitle()->onActionRender[] = callback($this, 'checkRole'); $ac->addAction('delete', 'delete!', true)->setIcon('normal delete')->hideTitle()->onActionRender[] = callback($this, 'checkRole'); }
protected function createComponentGridUsers($name) { $repository = $this->em->getRepository('User'); $persister = new \Gridder\Persisters\SessionPersister($this->getSession('usersGrid')); $queryBuilder = $this->em->createQueryBuilder()->select('u')->from('Entity\\User', 'u'); $source = new \Gridder\Sources\RepositorySource($repository, \Gridder\Sources\RepositorySource::HYDRATION_COMPLEX); //$source = new \Gridder\Sources\QueryBuilderSource($queryBuilder, \Gridder\Sources\QueryBuilderSource::HYDRATION_COMPLEX); $grid = new \Gridder\Gridder($source, $persister, $this, $name); $grid->autoAddFilters = true; $grid->addColumn('id'); $grid->addColumn('name'); $grid->addColumn('email'); $items = $this->em->getRepository('UserRole')->fetchPairs('id', 'name'); $grid->addColumn('role')->setArrayFilter($items); $grid->addColumn('permissions', 'entityChild')->setPath('role->permissions')->disableFilter(); $ac = $grid->addActionColumn('actions'); $ac->addAction('View', 'view')->setIcon('normal view')->hideTitle(); }
protected function createComponentGrid($name) { $grid = new \Gridder\Gridder($this, $name); $grid->setTranslator($this->context->translator); $persister = new \Gridder\Persisters\SessionPersister($this->getSession('gridder')); $grid->setPersister($persister); $array = array(); $start = microtime(); for ($i = 1; $i <= 2000; $i++) { $array[] = array('id' => (int) $i, 'name' => 'name' . $i); } $stop = microtime(); \Nette\Diagnostics\Debugger::fireLog($stop - $start); $dataSource = new \Gridder\Sources\ArraySource($array); $dataSource->setPrimaryKey('id'); $grid->setDataSource($dataSource); $grid->addColumn('id')->setAlias('Idecko')->setFilter('text'); $grid->addColumn('name')->setFilter('text'); /* $ac = $grid->addActionColumn('actions'); $ac->addAction('test', 'delete!'); $ac->addAction('test2', 'delete!'); $ac->addAction('test3', 'delete!'); */ /* $grid->addOperation('test', function($records){ $message = sprintf('You have selected %s records in method %s', count($records), __FUNCTION__); $type = 'ok'; return new \Gridder\Message($message, $type); })->setAlias('TEST'); $operation = new \Gridder\Operation('ohohoo'); $callback = callback($this, 'mehehe'); $operation->setAlias('BUBUBU')->setCallback($callback); $grid->addOperation($operation); * */ }
protected function createComponentGrid() { $dg = new \Gridder\Gridder(); $dg->setClass('users'); $repository = $this->context->documentManager->getRepository('User'); $source = new \Gridder\Sources\MongoRepositorySource($repository); //$source->prime('areaOfExpertise'); $storageSection = $this->getSession()->getSection('gridder_users' . $this->user->id); $persister = new \Gridder\Persisters\SessionPersister($storageSection); $dg->setSource($source); $dg->setPersister($persister); $dg->setPresenter($this); $dg->setInitialItemsPerPage(10); $dg->setPrimaryKey('id'); //$dg->addColumn('id')->setCaption('id'); $dg->addColumn('nick')->setSortable(TRUE)->setFilter('text'); $dg->addColumn('email')->setSortable(TRUE)->setFilter('text'); $dg->addColumn('projectCount')->setCaption('project count')->setSortable(TRUE); $dg->addColumn('account')->setSortable(TRUE)->setFilter('text'); $dg->addColumn('active')->setCaption('active')->setSortable(TRUE)->valueModifier[] = function ($boolean) { return $boolean === TRUE ? 'yes' : 'no'; }; $ac = $dg->addActionColumn('akcie'); $ac->addAction('detail', 'detail:')->setTitle('detail'); return $dg; }