How to exclude the last two columns when exporting?

How to exclude the last two columns when exporting?

TelmoFTelmoF Posts: 1Questions: 1Answers: 0
edited June 2016 in Free community support

I know about exportOptions and I know you can exclude the last column with :not(:last-child), but how can you exclude the last two columns?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49
    edited June 2016 Answer ✓

    https://datatables.net/extensions/buttons/examples/html5/columns.html

    Instead of using it to exclude, use it as a selector to include. So for those columns you wish to export, add a special class to the th elements '.export-col'.

    {
                    extend: 'pdfHtml5',
                    exportOptions: {
                        columns: ':visible(.export-col)'
                    }
     },
    

    --- or ---

    Add special class to columns not to be exported '.not-export-col'

    {
                    extend: 'pdfHtml5',
                    exportOptions: {
                        columns: ':visible(:not(.not-export-col))'
                    }
     },
    
This discussion has been closed.