@@ -26,6 +26,20 @@ abstract class DataTable implements DataTableButtons
2626 */
2727 protected $ dataTableVariable = 'dataTable ' ;
2828
29+ /**
30+ * List of columns to be excluded from export.
31+ *
32+ * @var string|array
33+ */
34+ protected $ excludeFromExport = [];
35+ 36+ /**
37+ * List of columns to be excluded from printing.
38+ *
39+ * @var string|array
40+ */
41+ protected $ excludeFromPrint = [];
42+ 2943 /**
3044 * List of columns to be exported.
3145 *
@@ -107,8 +121,8 @@ abstract class DataTable implements DataTableButtons
107121 * Process dataTables needed render output.
108122 *
109123 * @param string $view
110- * @param array $data
111- * @param array $mergeData
124+ * @param array $data
125+ * @param array $mergeData
112126 * @return mixed
113127 */
114128 public function render ($ view , $ data = [], $ mergeData = [])
@@ -198,7 +212,27 @@ protected function getDataForPrint()
198212 */
199213 protected function printColumns ()
200214 {
201- return is_array ($ this ->printColumns ) ? $ this ->printColumns : $ this ->getColumnsFromBuilder ();
215+ return is_array ($ this ->printColumns ) ? $ this ->printColumns : $ this ->getPrintColumnsFromBuilder ();
216+ }
217+ 218+ /**
219+ * Get filtered print columns definition from html builder.
220+ *
221+ * @return \Illuminate\Support\Collection
222+ */
223+ protected function getPrintColumnsFromBuilder ()
224+ {
225+ return $ this ->html ()->removeColumn (...$ this ->excludeFromPrint )->getColumns ();
226+ }
227+ 228+ /**
229+ * Get filtered export columns definition from html builder.
230+ *
231+ * @return \Illuminate\Support\Collection
232+ */
233+ protected function getExportColumnsFromBuilder ()
234+ {
235+ return $ this ->html ()->removeColumn (...$ this ->excludeFromExport )->getColumns ();
202236 }
203237
204238 /**
@@ -234,7 +268,7 @@ public function builder()
234268 /**
235269 * Map ajax response to columns definition.
236270 *
237- * @param mixed $columns
271+ * @param mixed $columns
238272 * @param string $type
239273 * @return array
240274 */
@@ -395,7 +429,7 @@ protected function getDataForExport()
395429 */
396430 private function exportColumns ()
397431 {
398- return is_array ($ this ->exportColumns ) ? $ this ->exportColumns : $ this ->getColumnsFromBuilder ();
432+ return is_array ($ this ->exportColumns ) ? $ this ->exportColumns : $ this ->getExportColumnsFromBuilder ();
399433 }
400434
401435 /**
@@ -434,11 +468,9 @@ public function snappyPdf()
434468 $ options = config ('datatables-buttons.snappy.options ' );
435469 $ orientation = config ('datatables-buttons.snappy.orientation ' );
436470
437- $ snappy ->setOptions ($ options )
438- ->setOrientation ($ orientation );
471+ $ snappy ->setOptions ($ options )->setOrientation ($ orientation );
439472
440- return $ snappy ->loadHTML ($ this ->printPreview ())
441- ->download ($ this ->getFilename () . '.pdf ' );
473+ return $ snappy ->loadHTML ($ this ->printPreview ())->download ($ this ->getFilename () . '.pdf ' );
442474 }
443475
444476 /**
@@ -470,7 +502,7 @@ public function addScopes(array $scopes)
470502 /**
471503 * Set a custom class attribute.
472504 *
473- * @param mixed $key
505+ * @param mixed $key
474506 * @param mixed|null $value
475507 * @return $this
476508 */
0 commit comments