1 | <?php |
||
29 | 1 | class Export extends Component implements \Nette\Application\IResponse |
|
30 | { |
||
31 | const ID = 'export'; |
||
32 | |||
33 | /** @var int */ |
||
34 | protected $fetchLimit = 100000; |
||
35 | |||
36 | /** @var array */ |
||
37 | protected $header = []; |
||
38 | |||
39 | /** @var callable */ |
||
40 | protected $customData; |
||
41 | |||
42 | /** |
||
43 | * @param Grid $grid |
||
44 | * @param string $label |
||
45 | */ |
||
46 | public function __construct(Grid $grid, $label = NULL) |
||
53 | |||
54 | /** |
||
55 | * @return void |
||
56 | */ |
||
57 | protected function printCsv() |
||
106 | |||
107 | /** |
||
108 | * Sets a limit which will be used in order to retrieve data from datasource. |
||
109 | * @param int $limit |
||
110 | * @return \Grido\Components\Export |
||
111 | */ |
||
112 | public function setFetchLimit($limit) |
||
117 | |||
118 | /** |
||
119 | * @return int |
||
120 | */ |
||
121 | public function getFetchLimit() |
||
125 | |||
126 | /** |
||
127 | * Sets a custom header of result CSV file (list of field names). |
||
128 | * @param array $header |
||
129 | * @return \Grido\Components\Export |
||
130 | */ |
||
131 | public function setHeader(array $header) |
||
136 | |||
137 | /** |
||
138 | * Sets a callback to modify output data. This callback must return a list of items. (array) function($datasource) |
||
139 | * DEBUG? You probably need to comment lines started with $httpResponse->setHeader in Grido\Components\Export.php |
||
140 | * @param callable $callback |
||
141 | * @return \Grido\Components\Export |
||
142 | */ |
||
143 | public function setCustomData($callback) |
||
148 | |||
149 | /** |
||
150 | * @internal |
||
151 | */ |
||
152 | public function handleExport() |
||
157 | |||
158 | /*************************** interface \Nette\Application\IResponse ***************************/ |
||
159 | |||
160 | /** |
||
161 | * Sends response to output. |
||
162 | * @param \Nette\Http\IRequest $httpRequest |
||
163 | * @param \Nette\Http\IResponse $httpResponse |
||
164 | * @return void |
||
165 | */ |
||
166 | public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse): void |
||
180 | } |
||
181 |