Exemple #1
0
	public function handleExport()
    {		
		$response = new \Nette\Application\Responses\CsvResponse($this->dataSource->getData(), 'faktura.csv');
		
		$response->setGlue( \Nette\Application\Responses\CsvResponse::SEMICOLON )
				->setOutputCharset( 'cp1250' )
				->setContentType( 'application/csv' )
				->setHeadingFormatter( 'strtoupper' )
				->setDataFormatter( 'trim' )
		;
		
        $this->presenter->sendResponse( $response );
	}
Exemple #2
0
 public function render()
 {
     $this->paginate();
     $this->filter();
     $count = $this->getCount();
     $this->getPaginator()->itemCount = $count;
     $this->template->results = $count;
     $this->template->columns = $this['columns']->components;
     $this->template->buttons = $this['buttons']->components;
     $this->template->globalButtons = $this['globalButtons']->components;
     $this->template->subGrids = $this['subGrids']->components;
     $this->template->paginate = $this->paginate;
     $this->template->colsCount = $this->getColsCount();
     $rows = $this->dataSource->getData();
     $this->template->rows = $rows;
     $this->template->primaryKey = $this->primaryKey;
     if ($this->hasActiveRowForm()) {
         $row = $rows[$this->activeRowForm]->toArray();
         foreach ($row as $name => $value) {
             if ($this->columnExists($name) && !empty($this['columns']->components[$name]->formRenderer)) {
                 $row[$name] = call_user_func($this['columns']->components[$name]->formRenderer, $row);
             }
             if (isset($this['gridForm'][$this->name]['rowForm'][$name])) {
                 $input = $this['gridForm'][$this->name]['rowForm'][$name];
                 if ($input instanceof \Nette\Forms\Controls\SelectBox) {
                     $items = $this['gridForm'][$this->name]['rowForm'][$name]->getItems();
                     if (in_array($row[$name], $items)) {
                         $row[$name] = array_search($row[$name], $items);
                     }
                 }
             }
         }
         $this['gridForm'][$this->name]['rowForm']->setDefaults($row);
         $this['gridForm'][$this->name]['rowForm']->addHidden($this->primaryKey, $this->activeRowForm);
     }
     if ($this->paginate) {
         $this->template->viewedFrom = ($this->getPaginator()->getPage() - 1) * $this->perPage + 1;
         $this->template->viewedTo = $this->getPaginator()->getLength() + ($this->getPaginator()->getPage() - 1) * $this->perPage;
     }
     $templatePath = !empty($this->templatePath) ? $this->templatePath : __DIR__ . "/templates/grid.latte";
     if ($this->getTranslator() instanceof \Nette\Localization\ITranslator) {
         $this->template->setTranslator($this->getTranslator());
     }
     $this->template->filters = $this->getFilterList();
     $this->template->setFile($templatePath);
     $this->template->render();
 }