Exporting specific columns dynamically

Exporting specific columns dynamically

yishayhyishayh Posts: 108Questions: 17Answers: 0


We have a datatable directive in angularJs.
Our directive is initialized dynamically with both the data and meta-data.
If We're correct, the way to define which columns go to the print/csv/etc is either by hidding them, or by defining the buttonCommon.columns with the wanted buttons and then extending the wanted export button.

The problem is that:
1. We want some of the information that shows in the table not to go to the export.
2. We cannot defined the columns using the
buttonCommon.columns = $('#'+scope.id).DataTable().columns(':not(.notForPrint)');
because the datatable is not initiated yet (the buttons are part of the datatable options.

How can We overcome this?
Many thanks,

This question has an accepted answers - jump to answer


  • allanallan Posts: 62,272Questions: 1Answers: 10,212 Site admin
    Answer ✓

    I'm not sure I understand why you can't use the :not() class selector? If the columns have the appropriate class, why can't you just use the following?:

                    extend: 'excelHtml5',
                    exportOptions: {
                        columns: ':not(.notForPrint)'

    The column selector is run when the export button is clicked, so it is at that point the selector would be resolved.


  • yishayhyishayh Posts: 108Questions: 17Answers: 0

    Hi Allan,

    sorry, this is so obvious, I don't know how I missed it.


This discussion has been closed.