Created
November 3, 2012 17:01
-
-
Save Twista/4007907 to your computer and use it in GitHub Desktop.
SitesGrid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Description of SitesGrid | |
| * | |
| * @author Michal Haták [Twista] <me@twista.cz> | |
| * @package cms | |
| */ | |
| class SitesGrid extends Nette\Application\UI\Control { | |
| /** @var SiteFacade */ | |
| private $dataSource; | |
| public function __construct(SiteFacade $dataSource) { | |
| parent::__construct(); | |
| $this->dataSource = $dataSource; | |
| } | |
| public function getGrid() { | |
| $grid = new Nextras\Datagrid\Datagrid; | |
| $grid->addColumn('id'); | |
| $grid->addColumn('name', 'Název')->enableSort(); | |
| $grid->addColumn('body', 'Text')->enableSort(); | |
| // template | |
| $grid->setCellsTemplate(__DIR__ . '/templates/sitesgrid.columns.latte'); | |
| $grid->setDatasourceCallback(function($filter, $order) { | |
| $selection = $this->dataSource->getAll(); | |
| return $selection; | |
| }); | |
| $grid->setFilterFormFactory(function(){ | |
| $this->redirect('Homepage:defualt'); | |
| /* | |
| $form = new Nette\Forms\Container; | |
| $form->addText('name', 'Název'); | |
| $form->addText('body', 'Text'); | |
| // set your own fileds, inputs | |
| // these buttons are not compulsory | |
| $form->addSubmit('filter', 'filtrovat')->getControlPrototype()->class = 'btn btn-primary'; | |
| $form->addSubmit('cancel', 'zrušit filtr')->getControlPrototype()->class = 'btn'; | |
| return $form;*/ | |
| }); | |
| $grid->setEditFormFactory(function($row) { | |
| $form = new Nette\Forms\Container; | |
| //$form->addDateTimePicker('created_time'); | |
| $form->addText('name') | |
| ->setRequired(); | |
| $form->addTextArea('body'); | |
| // set your own conditions | |
| // set your own fileds, inputs | |
| // these buttons are not compulsory | |
| $form->addSubmit('save', 'Uložit')->getControlPrototype()->class = 'btn btn-primary'; | |
| $form->addSubmit('cancel', 'Zrušit')->getControlPrototype()->class = 'btn'; | |
| $form->setDefaults($row->getValues()); | |
| return $form; | |
| }); | |
| return $grid; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment