colvis export all visible except last column

colvis export all visible except last column

lenamtllenamtl Posts: 265Questions: 65Answers: 1
edited June 2016 in Free community support

Hi

How can I configure the export and print to NOT export or print
the last column (-1) but export/print other visible column (i'm also using colvis button)?
how can I passed these 2 values to the exportOption column ?
exportOptions: {
columns: ':visible',
}

I have tried
columns: [':visible', ':not(:last-child)']
and
columns: [':visible', ':not(:-1)']
with no luck

If I use only columns: ':not(:last-child)', without :visible
it's not exporting the last column which is ok but if I hide column with colvis it is exporting all columns even hidden one.

Any clue?

This question has an accepted answers - jump to answer

Answers

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    This is important that I use visible and not -1
    I cannot set it to individual columns
    As the table may have more or less columns (dynamically rendered)
    so I cannot set column number as I don't in advance how many column will be generated and which order they will have.

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1
    edited June 2016

    Here is my temporary solution

    I set both visible and not last-child for export button
    here is the correct syntax.
    columns: [':visible :not(:last-child)']

    I have set colReorder to fixedColumnsRight: 1, so latest column is not movable

    And to make sure the latest column is always the same, I have removed the column from the column list if colvis so it is always visible.

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    Are you just concerned with last column or a particular column? Also, check out my response in a similar post https://datatables.net/forums/discussion/comment/94612/#Comment_94612

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    Hi,

    I need it for a specific column which is a 'Tools' column.
    I will try your solution which as a different approach.

    Thanks for the suggestion

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1
    edited June 2016

    I have tried your solution with no luck

    I set the class not-export-col to the TH of one column that I don't want to export

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

    ```
    the column is still exported

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

    http://live.datatables.net/cewaqige/2/edit

    Got it working. My columns string was incorrect.

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    Thanks

This discussion has been closed.