/** * Render export button * @return Html */ public function render() { $a = Html::el('a', ['class' => [$this->class], 'title' => $this->grid->getTranslator()->translate($this->getTitle()), 'href' => $this->link]); $this->tryAddIcon($a, $this->getIcon(), $this->grid->getTranslator()->translate($this->getTitle())); $a->addText($this->grid->getTranslator()->translate($this->text)); if ($this->isAjax()) { $a->class[] = 'ajax'; } return $a; }
/** * Render row item detail button * @param Row $row * @return Html */ public function renderButton($row) { $a = Html::el('a')->href($this->grid->link('getItemDetail!', ['id' => $row->getId()]))->data('toggle-detail', $row->getId())->data('toggle-detail-grid', $this->grid->getName()); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); $a->addText($this->text); if ($this->title) { $a->title($this->grid->getTranslator()->translate($this->title)); } if ($this->class) { $a->class($this->class); } return $a; }
/** * Render toolbar button * @return Html */ public function renderButton() { $link = $this->createLink($this->grid, $this->href, $this->params); $a = Html::el('a')->href($link); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); $a->addText($this->grid->getTranslator()->translate($this->text)); if ($this->title) { $a->title($this->grid->getTranslator()->translate($this->title)); } if ($this->class) { $a->class($this->class); } return $a; }
/** * Generates control's HTML element. * @param string * @return Nette\Utils\Html */ public function getControl($caption = NULL) { $el = parent::getControl(''); $el->type = 'submit'; $el->class = $this->getClass(); if ($this->getIcon()) { $el->addHtml(Html::el('span')->class(DataGrid::$icon_prefix . $this->getIcon())); if (strlen($this->getText())) { $el->addHtml(' '); } } $el->addText($this->grid->getTranslator()->translate($this->getText())); return $el; }
/** * Call export callback * @param array $data * @param DataGrid $grid * @return void */ public function invoke(array $data, DataGrid $grid) { $columns = $this->getColumns() ?: $grid->getColumns(); $csv_data_model = new CsvDataModel($data, $columns, $grid->getTranslator()); if ($grid->getPresenter() instanceof Nette\Application\UI\Presenter) { $grid->getPresenter()->sendResponse(new CSVResponse($csv_data_model->getSimpleData(), $this->name, $this->output_encoding, $this->delimiter)); exit(0); } }
/** * @return Html */ public function renderButton() { $button = Html::el('button')->type('button')->data('toggle', 'dropdown'); $this->tryAddIcon($button, $this->getIcon(), $this->getText()); if (!empty($this->attributes)) { $button->addAttributes($this->attributes); } $button->addText($this->grid->getTranslator()->translate($this->name)); if ($this->hasCaret()) { $button->addHtml(' '); $button->addHtml('<i class="caret"></i>'); } if ($this->getTitle()) { $button->title($this->grid->getTranslator()->translate($this->getTitle())); } if ($this->getClass()) { $button->class($this->getClass() . ' dropdown-toggle'); } return $button; }
/** * Render row item detail button * @return Html */ public function renderButtonAdd() { $a = Html::el('a')->data('datagrid-toggle-inline-add', TRUE); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); $a->addText($this->text); if ($this->title) { $a->title($this->grid->getTranslator()->translate($this->title)); } if ($this->class) { $a->class($this->class); } return $a; }
/** * Translator helper * @param string $message * @return string */ protected function translate($message) { return $this->grid->getTranslator()->translate($message); }