From 0365ba7f773a1aa26ac7c70d9b1b14ff2c6458e9 Mon Sep 17 00:00:00 2001 From: AntikCz Date: Fri, 26 Feb 2016 19:46:04 +0100 Subject: [PATCH] Support for multiple export (Closes #262) --- src/Components/Container.php | 56 +++++- src/Components/Export.php | 180 ------------------ src/Components/Exports/BaseExport.php | 154 +++++++++++++++ src/Components/Exports/CsvExport.php | 78 ++++++++ src/templates/default.latte | 7 +- tests/Components/Export.phpt | 22 ++- tests/DataSources/ArraySource.phpt | 3 +- tests/DataSources/DibiFluent.phpt | 3 +- tests/DataSources/Doctrine.phpt | 3 +- tests/DataSources/NetteDatabase.phpt | 3 +- tests/DataSources/TestCase.php | 2 +- .../files/doctrine/proxies/.htaccess | 2 +- tests/DataSources/files/export.expect | 2 +- tests/DataSources/files/render.expect | 2 +- tests/DataSources/files/users.s3db | Bin tests/DataSources/files/users.s3db.editable | Bin 0 -> 20480 bytes tests/Grid/files/render.editable.expect | 2 +- tests/Grid/files/render.expect | 5 +- tests/Grid/render.editable.phpt | 3 +- tests/Grid/render.phpt | 4 +- 20 files changed, 322 insertions(+), 209 deletions(-) delete mode 100644 src/Components/Export.php create mode 100644 src/Components/Exports/BaseExport.php create mode 100644 src/Components/Exports/CsvExport.php mode change 100755 => 100644 src/templates/default.latte mode change 100755 => 100644 tests/DataSources/files/users.s3db create mode 100644 tests/DataSources/files/users.s3db.editable diff --git a/src/Components/Container.php b/src/Components/Container.php index 2d7198b4..45058622 100644 --- a/src/Components/Container.php +++ b/src/Components/Container.php @@ -11,6 +11,8 @@ namespace Grido\Components; +use Grido\Components\Exports\BaseExport; +use Grido\Components\Exports\CsvExport; use Grido\Grid; use Grido\Helpers; use Grido\Components\Actions\Action; @@ -94,12 +96,37 @@ public function getOperation($need = TRUE) /** * Returns export component. + * @param string $name * @param bool $need - * @return Export + * @return CsvExport + */ + public function getExport($name = NULL, $need = TRUE) + { + if (is_bool($name) || $name === NULL) { // deprecated + trigger_error('This usage of ' . __METHOD__ . '() is deprecated, + please write name of export to first parameter.', E_USER_DEPRECATED); + $export = $this->getComponent(BaseExport::ID, $name); + if ($export) { + $export = $export->getComponent(CsvExport::CSV_ID, is_bool($name) ? $name : TRUE); + } + return $export; + } + return $this->hasExport() + ? $this->getComponent(BaseExport::ID)->getComponent(Helpers::formatColumnName($name), $need) + : NULL; + } + + /** + * @param bool $need + * @return BaseExport[] */ - public function getExport($need = TRUE) + public function getExports($need = TRUE) { - return $this->getComponent(Export::ID, $need); + $export = $this->getComponent(BaseExport::ID, $need); + if ($export) { + $export = $export->getComponents(); + } + return $export; } /**********************************************************************************************/ @@ -185,7 +212,7 @@ public function hasExport($useCache = TRUE) $hasExport = $this->hasExport; if ($hasExport === NULL || $useCache === FALSE) { - $hasExport = (bool) $this->getComponent(Export::ID, FALSE); + $hasExport = (bool) $this->getExports(FALSE); $this->hasExport = $useCache ? $hasExport : NULL; } @@ -361,10 +388,29 @@ public function setOperation(array $operations, $onSubmit) /** * @param string $label of exporting file * @return Export + * + * @deprecated */ public function setExport($label = NULL) { - return new Export($this, $label); + trigger_error(__METHOD__ . '() is deprecated; use addExport instead.', E_USER_DEPRECATED); + return $this->addExport(new CsvExport($label), CsvExport::CSV_ID); + } + + /** + * @param BaseExport $export + * @param string $name Component name + * @return BaseExport + */ + public function addExport(BaseExport $export, $name) + { + $container = $this->getComponent(BaseExport::ID, FALSE); + if (!$container) { + $container = new \Nette\ComponentModel\Container(); + $this->addComponent($container, BaseExport::ID); + } + $container->addComponent($export, $name); + return $export; } /** diff --git a/src/Components/Export.php b/src/Components/Export.php deleted file mode 100644 index ca4fb713..00000000 --- a/src/Components/Export.php +++ /dev/null @@ -1,180 +0,0 @@ -grid = $grid; - $this->label = $label; - - $grid->addComponent($this, self::ID); - } - - /** - * @return void - */ - protected function printCsv() - { - $escape = function($value) { - return preg_match("~[\"\n,;\t]~", $value) || $value === "" - ? '"' . str_replace('"', '""', $value) . '"' - : $value; - }; - - $print = function(array $row) { - print implode(',', $row) . "\n"; - }; - - $columns = $this->grid[Column::ID]->getComponents(); - - $header = []; - $headerItems = $this->header ? $this->header : $columns; - foreach ($headerItems as $column) { - $header[] = $this->header - ? $escape($column) - : $escape($column->getLabel()); - } - - $print($header); - - $datasource = $this->grid->getData(FALSE, FALSE, FALSE); - $iterations = ceil($datasource->getCount() / $this->fetchLimit); - for ($i = 0; $i < $iterations; $i++) { - $datasource->limit($i * $this->fetchLimit, $this->fetchLimit); - $data = $this->customData - ? call_user_func_array($this->customData, [$datasource]) - : $datasource->getData(); - - foreach ($data as $items) { - $row = []; - - $columns = $this->customData - ? $items - : $columns; - - foreach ($columns as $column) { - $row[] = $this->customData - ? $escape($column) - : $escape($column->renderExport($items)); - } - - $print($row); - } - } - } - - /** - * Sets a limit which will be used in order to retrieve data from datasource. - * @param int $limit - * @return \Grido\Components\Export - */ - public function setFetchLimit($limit) - { - $this->fetchLimit = (int) $limit; - return $this; - } - - /** - * @return int - */ - public function getFetchLimit() - { - return $this->fetchLimit; - } - - /** - * Sets a custom header of result CSV file (list of field names). - * @param array $header - * @return \Grido\Components\Export - */ - public function setHeader(array $header) - { - $this->header = $header; - return $this; - } - - /** - * Sets a callback to modify output data. This callback must return a list of items. (array) function($datasource) - * DEBUG? You probably need to comment lines started with $httpResponse->setHeader in Grido\Components\Export.php - * @param callable $callback - * @return \Grido\Components\Export - */ - public function setCustomData($callback) - { - $this->customData = $callback; - return $this; - } - - /** - * @internal - */ - public function handleExport() - { - !empty($this->grid->onRegistered) && $this->grid->onRegistered($this->grid); - $this->grid->presenter->sendResponse($this); - } - - /*************************** interface \Nette\Application\IResponse ***************************/ - - /** - * Sends response to output. - * @param \Nette\Http\IRequest $httpRequest - * @param \Nette\Http\IResponse $httpResponse - * @return void - */ - public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse) - { - $encoding = 'utf-8'; - $label = $this->label - ? ucfirst(Strings::webalize($this->label)) - : ucfirst($this->grid->getName()); - - $httpResponse->setHeader('Content-Encoding', $encoding); - $httpResponse->setHeader('Content-Type', "text/csv; charset=$encoding"); - $httpResponse->setHeader('Content-Disposition', "attachment; filename=\"$label.csv\""); - - print chr(0xEF) . chr(0xBB) . chr(0xBF); //UTF-8 BOM - $this->printCsv(); - } -} diff --git a/src/Components/Exports/BaseExport.php b/src/Components/Exports/BaseExport.php new file mode 100644 index 00000000..a516d4bd --- /dev/null +++ b/src/Components/Exports/BaseExport.php @@ -0,0 +1,154 @@ +label = $label; + $this->monitor('Grido\Grid'); + } + + protected function attached($presenter) + { + parent::attached($presenter); + if ($presenter instanceof Grid) { + $this->grid = $presenter; + } + } + + /** + * @return void + */ + abstract protected function printData(); + + /** + * @param \Nette\Http\IResponse $httpResponse + * @param string $label + * @return void + */ + abstract protected function setHttpHeaders(\Nette\Http\IResponse $httpResponse, $label); + + /** + * @param string $title + * @return self + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Sets a limit which will be used in order to retrieve data from datasource. + * @param int $limit + * @return \Grido\Components\Export + */ + public function setFetchLimit($limit) + { + $this->fetchLimit = (int) $limit; + return $this; + } + + /** + * @return int + */ + public function getFetchLimit() + { + return $this->fetchLimit; + } + + /** + * Sets a custom header of result CSV file (list of field names). + * @param array $header + * @return \Grido\Components\Export + */ + public function setHeader(array $header) + { + $this->header = $header; + return $this; + } + + /** + * Sets a callback to modify output data. This callback must return a list of items. (array) function($datasource) + * DEBUG? You probably need to comment lines started with $httpResponse->setHeader in Grido\Components\Export.php + * @param callable $callback + * @return \Grido\Components\Export + */ + public function setCustomData($callback) + { + $this->customData = $callback; + return $this; + } + + /** + * @internal + */ + public function handleExport() + { + !empty($this->grid->onRegistered) && $this->grid->onRegistered($this->grid); + $this->grid->presenter->sendResponse($this); + } + + /*************************** interface \Nette\Application\IResponse ***************************/ + + /** + * Sends response to output. + * @param \Nette\Http\IRequest $httpRequest + * @param \Nette\Http\IResponse $httpResponse + * @return void + */ + public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse) + { + $label = $this->label + ? ucfirst(Strings::webalize($this->label)) + : ucfirst($this->grid->name); + + $this->setHttpHeaders($httpResponse, $label); + + print chr(0xEF) . chr(0xBB) . chr(0xBF); //UTF-8 BOM + $this->printData(); + } +} diff --git a/src/Components/Exports/CsvExport.php b/src/Components/Exports/CsvExport.php new file mode 100644 index 00000000..8d8fc50f --- /dev/null +++ b/src/Components/Exports/CsvExport.php @@ -0,0 +1,78 @@ +grid[Column::ID]->getComponents(); + + $header = []; + $headerItems = $this->header ? $this->header : $columns; + foreach ($headerItems as $column) { + $header[] = $this->header + ? $escape($column) + : $escape($column->getLabel()); + } + + $print($header); + + $datasource = $this->grid->getData(FALSE, FALSE, FALSE); + $iterations = ceil($datasource->getCount() / $this->fetchLimit); + for ($i = 0; $i < $iterations; $i++) { + $datasource->limit($i * $this->fetchLimit, $this->fetchLimit); + $data = $this->customData + ? call_user_func_array($this->customData, [$datasource]) + : $datasource->getData(); + + foreach ($data as $items) { + $row = []; + + $columns = $this->customData + ? $items + : $columns; + + foreach ($columns as $column) { + $row[] = $this->customData + ? $escape($column) + : $escape($column->renderExport($items)); + } + + $print($row); + } + } + } + + /** + * @param IResponse $httpResponse + * @param string $label + */ + protected function setHttpHeaders(IResponse $httpResponse, $label) + { + $encoding = 'utf-8'; + $httpResponse->setHeader('Content-Encoding', $encoding); + $httpResponse->setHeader('Content-Type', "text/csv; charset=$encoding"); + $httpResponse->setHeader('Content-Disposition', "attachment; filename=\"$label.csv\""); + } +} diff --git a/src/templates/default.latte b/src/templates/default.latte old mode 100755 new mode 100644 index 86109cc6..891fed08 --- a/src/templates/default.latte +++ b/src/templates/default.latte @@ -144,9 +144,12 @@ {/block} {input $form[buttons][perPage], class => 'hide'} - - {_'Grido.Export'} + {if $control->hasExport()} + + {var $title = $export->title ? : $template->translate('Grido.ExportAllItems')} + {_'Grido.Export'} + {/if} {input $form[buttons][reset]} diff --git a/tests/Components/Export.phpt b/tests/Components/Export.phpt index 9a33aec6..5c1cd92d 100644 --- a/tests/Components/Export.phpt +++ b/tests/Components/Export.phpt @@ -9,6 +9,8 @@ namespace Grido\Tests; +use Grido\Components\Exports\BaseExport; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid, Grido\Tests\Helper, @@ -47,7 +49,7 @@ class ExportTest extends \Tester\TestCase $grid = new Grid; Assert::false($grid->hasExport()); - $grid->setExport(); + $grid->addExport(new CsvExport(), 'csv'); Assert::false($grid->hasExport()); Assert::true($grid->hasExport(FALSE)); } @@ -57,15 +59,15 @@ class ExportTest extends \Tester\TestCase $grid = new Grid; $label = 'export'; - $grid->setExport($label); - $component = $grid->getExport(); - Assert::type('\Grido\Components\Export', $component); + $grid->addExport(new CsvExport($label), 'csv'); + $component = $grid->getExport('csv'); + Assert::type('\Grido\Components\Exports\BaseExport', $component); Assert::same($label, $component->label); - unset($grid[Export::ID]); + $grid[BaseExport::ID]->removeComponent($grid->getExport('csv')); // getter Assert::exception(function() use ($grid) { - $grid->getExport(); + $grid->getExport('csv'); }, 'Nette\InvalidArgumentException'); } @@ -95,11 +97,11 @@ class ExportTest extends \Tester\TestCase ->setSortable(); $grid->addColumnText('country', 'Country') ->setFilterText(); - $grid->setExport($label); + $grid->addExport(new CsvExport($label), 'csv'); }); $params = [ - 'do' => 'grid-export-export', + 'do' => 'grid-export-csv-export', 'grid-sort' => ['name' => \Grido\Components\Columns\Column::ORDER_DESC], 'grid-filter' => ['country' => 'Switzerland'], 'grid-page' => 2 @@ -134,7 +136,7 @@ class ExportTest extends \Tester\TestCase $grid->addColumnText('firstname', 'Name') ->setSortable(); - $grid->setExport() + $grid->addExport(new CsvExport(), 'csv') ->setHeader(['"Jméno"', "Příjmení\t", "Karta\n", 'Jméno,Příjmení']) ->setCustomData(function(ArraySource $source) { $data = $source->getData(); @@ -151,7 +153,7 @@ class ExportTest extends \Tester\TestCase }); }); - $params = ['do' => 'grid-export-export']; + $params = ['do' => 'grid-export-csv-export']; ob_start(); Helper::request($params)->send(mock('\Nette\Http\IRequest'), new Response); diff --git a/tests/DataSources/ArraySource.phpt b/tests/DataSources/ArraySource.phpt index 48fcb762..16565308 100644 --- a/tests/DataSources/ArraySource.phpt +++ b/tests/DataSources/ArraySource.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid, Grido\Components\Filters\Condition; @@ -58,7 +59,7 @@ class ArraySourceTest extends DataSourceTestCase return $row['centimeters'] >= 180; }); - $grid->setExport(); + $grid->addExport(new CsvExport(), 'csv'); })->run(); } diff --git a/tests/DataSources/DibiFluent.phpt b/tests/DataSources/DibiFluent.phpt index 93642f65..58437c05 100644 --- a/tests/DataSources/DibiFluent.phpt +++ b/tests/DataSources/DibiFluent.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid, Grido\Components\Filters\Condition; @@ -60,7 +61,7 @@ class DibiFluentTest extends DataSourceTestCase }); $limit = 100; - $export = $grid->setExport()->setFetchLimit($limit); + $export = $grid->addExport(new CsvExport(), 'csv')->setFetchLimit($limit); Assert::same($limit, $export->getFetchLimit()); })->run(); diff --git a/tests/DataSources/Doctrine.phpt b/tests/DataSources/Doctrine.phpt index 7bfbeb1a..715583d1 100644 --- a/tests/DataSources/Doctrine.phpt +++ b/tests/DataSources/Doctrine.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert; use Grido\Grid; use Grido\Components\Filters\Condition; @@ -65,7 +66,7 @@ class DoctrineTest extends DataSourceTestCase $qb->andWhere("a.centimeters >= :height")->setParameter('height', 180); }); - $grid->setExport(); + $grid->addExport(new CsvExport(), 'csv'); })->run(); } diff --git a/tests/DataSources/NetteDatabase.phpt b/tests/DataSources/NetteDatabase.phpt index 3dbb4dc3..ed5c3123 100644 --- a/tests/DataSources/NetteDatabase.phpt +++ b/tests/DataSources/NetteDatabase.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid, Grido\Components\Filters\Condition; @@ -55,7 +56,7 @@ class NetteDatabaseTest extends DataSourceTestCase $fluent->where('[centimeters] >= ?', 180); }); - $grid->setExport(); + $grid->addExport(new CsvExport(), 'csv'); })->run(); } diff --git a/tests/DataSources/TestCase.php b/tests/DataSources/TestCase.php index 43677dd0..ec87d0c9 100644 --- a/tests/DataSources/TestCase.php +++ b/tests/DataSources/TestCase.php @@ -105,7 +105,7 @@ function testNullableForeignKey() function testExport() { Helper::$presenter->forceAjaxMode = FALSE; - $params = $this->params + ['do' => 'grid-export-export']; + $params = $this->params + ['do' => 'grid-export-csv-export']; ob_start(); Helper::request($params)->send(mock('\Nette\Http\IRequest'), new \Nette\Http\Response); diff --git a/tests/DataSources/files/doctrine/proxies/.htaccess b/tests/DataSources/files/doctrine/proxies/.htaccess index 74e020d6..22b9ed25 100644 --- a/tests/DataSources/files/doctrine/proxies/.htaccess +++ b/tests/DataSources/files/doctrine/proxies/.htaccess @@ -1,2 +1,2 @@ -Order Allow,Deny +Order Allow,Deny Deny from all \ No newline at end of file diff --git a/tests/DataSources/files/export.expect b/tests/DataSources/files/export.expect index 4b6e8acd..964d97eb 100644 --- a/tests/DataSources/files/export.expect +++ b/tests/DataSources/files/export.expect @@ -1,5 +1,5 @@ Firstname,Surname,Gender,Phone,Country -Marij,"Rašpolić Příliš, žluťoučký ""kůň"" úpěl 'ďábelské' ódy. +Marij,"Rašpolić Příliš, žluťoučký ""kůň"" úpěl 'ďábelské' ódy. and newline ""test"";",male,905-895-1107,Australia James,Vallace,male,04774 25 83 51,Australia Juhana,Uusipaikka,male,519-896-1068,Australia diff --git a/tests/DataSources/files/render.expect b/tests/DataSources/files/render.expect index 3a1bdb8a..628c3dfd 100644 --- a/tests/DataSources/files/render.expect +++ b/tests/DataSources/files/render.expect @@ -68,7 +68,7 @@ - Export + Export diff --git a/tests/DataSources/files/users.s3db b/tests/DataSources/files/users.s3db old mode 100755 new mode 100644 diff --git a/tests/DataSources/files/users.s3db.editable b/tests/DataSources/files/users.s3db.editable new file mode 100644 index 0000000000000000000000000000000000000000..c68d0d12c807858c730f93dc9a576356358bfbdc GIT binary patch literal 20480 zcmeHPYiu0Xb)K24hfPwk#uCA@EX@&BMr6&M?#@2PieatDr9_HcQhbP%5=FkddzU-h z*`3WiBrj39pdM7w!iW>VfbG~xWLXJp>k&Y;;u=VkfKnd)Q3G-7qODV)LG2nX5C=_+ z#*I<*+_}5U;aYLpMowgV7Z}btXLruMbME7u`OXbu}+a*aH z$1T9I6^_kt+zv-O96TJ=kC(2>>dyRaY`p?!ztQkxpERJ>ZaqnM-x(aMGDt%YLY0MA>EQq9>wmSWsm~{DXp497oO>76XLPXW5$xE8%O9yUbRqVkv*5V$Zov8{2LqC+50} z;+f>|{+XJIt5>cyua@cVuh|Q32MpDBGSRZJt+kb3F1U9=$A%so*7VmMGB7Z;FDQ|; zqD|(Bc|!wB@tNuI;Uru?mPk(b(@W+F%nGw^P~2~_nrYee?r-#EWd_~otLjjA2O9?3 z)kz9i({Uza63e>LwKma7DQ6T((J7=>yH&kBrI~gvgUdI%G@Z7~r5pA&O^UWwAT}|f z&3g0DZVio3CWiMU=@f*CzNY_u(qv*NF_}mXB&KS^Lze>^A-X~a6Qc=OKm+lqf%ss8 zN@gYo>5{5Qn))`u)DeYuIP??rBlI`uyXblJW%PNpj2=LFbO7x|pFlE_P&53b@o8A# zLuG-MB^!wynl+pzIxc4JTp~!^;aD?8*uOK~)Is*eq`uLt@{2s-kJ1R-Dfmh2~+nHfs)<820&=A^3e( z8`6rdrUB4Itf>;#iY+R9lOcNuc;sSvOAIun7Y7zeIwwt%l9ST4^yXe9Zcpc?j%oHH zF{y&)kAv7JM!7W=rLyGJs`n={8S~dfR?YLvvriMRu2NJum<8oNna1)HEh)#3p zKhWFg-_gIIAEH;#OXz#(+vr7f1zkX=(RuVFdIUZ6p&I(e%`_}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!E6nyP z3$5y_1Kw@*@k7gVptExeIN4f0U`4Bjq+MAWs1V0W8H3?VhnF)f^Mmmoja4=9PVaXGa(Q!qdA@eJAy+Ut8szggKAYTDHHgk>7Pb_!Q zUUtzPn`xegoB|XCY?x&rku>zjg`CoH!26Z)+73)#k^vJob%YsPl;HqzLsSHD0EI zHO8XZst}YqM8ni=!rTYDxqW!{(1`^)TiV6@R&#@UH9dp(l6i2=*l`(|acgx(17Vnj zQM$o}=&h-+DF@c<_;V*_K{+JZhC6DNDsiZO0cWI>Ll|od#LQ|niCht_X$Dr08dPZZ z2n+|<3CrJo>EMY$P)*(3YQKkwVQOSAE@&C-Fa|t5aNgl?9epSgQ6x1)(>>8BjEEBT zOvrQ7Cjww=@On_b%qHXkZ2_0Ty=NQ^R;J6z6?RQ$L%|5RDOwB!mBzHz*rWD^xf6FW zwZql9IRaDLI)Gs{rXgN)ImnI9GC{pN2}Qx{D`6=H{-4$b(QIab73n;CJ}C(66XGhmThSCREK+Yt_oG8g575qUfv}=tlVJ!~ zj47;R+ofb6-?f*hP`Ts_dRP0Ukz zDS!s~GnfS4ZTqRiOOv1wa+SlY3ip~vjfFhRfc)hZH}$30qK1{98hW{9Y0%31XV zy<5up*`@pFowthvG*qKo%D7oDtf|G7XLP-!yNt}ZI=jNo=Yzbb55hG%iJ_K#jVWHJ ztnl05OyBX{2!{v<&HLX82bI%zfNx3-0O)CaZn_2LZhzlue{hpq`*UXfd)EF`U(>F< zSN%b%{i(d@?WPSsy6^u&{*Qw+;C3`C{2RQ(BlADx|BR1te_NTVAG~_W2E6D7Rttp6jz+ra - Export + Export diff --git a/tests/Grid/files/render.expect b/tests/Grid/files/render.expect index e16cf7cf..4f1781de 100644 --- a/tests/Grid/files/render.expect +++ b/tests/Grid/files/render.expect @@ -72,7 +72,10 @@ - Export + Export + + + Export diff --git a/tests/Grid/render.editable.phpt b/tests/Grid/render.editable.phpt index a4932d58..1b2afefd 100644 --- a/tests/Grid/render.editable.phpt +++ b/tests/Grid/render.editable.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid; @@ -58,7 +59,7 @@ test(function() ->elementPrototype = \Nette\Utils\Html::el('button'); $grid->setOperation(['print' => 'Print'], function(){}); - $grid->setExport(); + $grid->addExport(new CsvExport(), 'csv'); })->run(); diff --git a/tests/Grid/render.phpt b/tests/Grid/render.phpt index 5c48c57d..604601c8 100644 --- a/tests/Grid/render.phpt +++ b/tests/Grid/render.phpt @@ -9,6 +9,7 @@ namespace Grido\Tests; +use Grido\Components\Exports\CsvExport; use Tester\Assert, Grido\Grid; @@ -55,7 +56,8 @@ test(function() ->elementPrototype = \Nette\Utils\Html::el('button'); $grid->setOperation(['print' => 'Print'], function(){}); - $grid->setExport(); + $grid->addExport(new CsvExport('myLabel'), 'csv'); + $grid->addExport(new CsvExport('myLabel'), 'csv2'); })->run();