Export visible columns within a subset.

Export visible columns within a subset.

gastongrgastongr Posts: 2Questions: 1Answers: 0
edited November 2016 in Free community support

Hi there, first i'd like to say thanks to all the development team behind DataTables for providing this excellent plugin!
It amazes me everyday while discovering the incredible flexibility and great features it has!

Question:
I am using the export buttons extension along with the column visibility button. The thing is that my table has a few columns that should never be exported but that are always visible. I want to be able to export visible columns within a subset of columns.

Based on Column selectors Example

I know i can use

buttons: [
    {
        extend: 'excel',
        exportOptions: {
            columns: ':visible'
        }
    }
]

or

buttons: [
    {
        extend: 'excel',
        exportOptions: {
            columns: [0, 1, 2]
        }
    }
]

But i am after a combination of these. I mean, only select columns 0, 1, 2 that are visible.

I also read the documentation for the column-selector data type but couldn't figure it out.
Any help is appreciated :)

Thanks again for the great plugin!

Answers

  • gastongrgastongr Posts: 2Questions: 1Answers: 0

    I just figured it out, in case someone finds this useful:

    I added class="exportable" to the headings of columns i want to be exportable, and then configured buttons like this:

    buttons: [
        {
            extend: 'excel',
            exportOptions: {
                columns: ':visible.exportable'
            }
        }
    ]
    
  • WebCodexWebCodex Posts: 71Questions: 13Answers: 3
    edited November 2016
    Whats wrong with using this??
    
    exportOptions: {
          columns: [1,2,3,4,5,6]
    }
    
This discussion has been closed.