Editor + Column Visibility Export

Editor + Column Visibility Export

fcssbanasfcssbanas Posts: 8Questions: 3Answers: 0

Hi there -

I am running Editor 1.6.2 on the latest DT (1.10.15). I included the column visibility option, and it works great - hides the columns as it should. However, when trying to export this fields, regardless of which type (CSV, print, PDF, Excel), the columns no longer hide. All are visible.

Is there a workaround on this by any chance? Thanks!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    edited May 2017 Answer ✓

    Maybe this will help:

    exportOptions: {
         columns: ':visible'
    }
    

    An example can be seen here:
    https://datatables.net/extensions/buttons/examples/print/columns.html

    Kevin

  • fcssbanasfcssbanas Posts: 8Questions: 3Answers: 0

    Thanks, Kevin! That set me on the right path.

    And for those who need column visibility in a collection, here's what I did:

        {
           extend: 'collection',
          text: 'Export',
          buttons: [
            {
              extend: 'copy',
              text: 'Copy',
              exportOptions: {
                columns: ':visible'
              }
            },
            {
              extend: 'print',
              text: 'Print',
              exportOptions: {
                columns: ':visible'
              }
            }
           ]
         }
    

    with adding as many buttons as you need.

This discussion has been closed.