Select columns before export besides of the visible columns

Select columns before export besides of the visible columns

JLLBJLLB Posts: 2Questions: 1Answers: 0
edited March 2018 in Free community support

Hi,

I would like to know if it´s possible in any export button show a modal window like the 'colvis' option,

But in this case should be to select which columns to export besides the columns that are visible.

This is a sample of the object:

var assetLocDataTable = $('#tableAssetLocations').DataTable( {
                  "pageLength": 100,
                  "stateSave": true,
                  "stateDuration": 0,
                  "scrollY": "800px",
                  "scrollCollapse": true,
                  "sScrollX": "100%",
                  "sScrollXInner": "100%",
                  "aoColumnDefs": [
                      { "sWidth": "70px", "aTargets": '_all' }
                      ],
                  colReorder: true,
                  dom: 'Bfrtip',
                      buttons: [
                        {extend: 'csv',text: 'Export To CSV',exportOptions: {columns: 'visible'}},
                        {extend: 'copy',text: 'Copy To Clipboard',exportOptions: {columns: ':visible'}},
                        {extend: 'colvis',postfixButtons: [ 'colvisRestore' ],collectionLayout: 'four-column'},
                      ],
                  } );

Thanks!

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Here are some examples of column selectors:
    https://datatables.net/extensions/buttons/examples/html5/columns.html

    Kevin

  • JLLBJLLB Posts: 2Questions: 1Answers: 0
    edited March 2018

    Thanks Kevin for answering!

    I saw that samples, but what I´m asking for is to make a window like the one that appears when you press 'Column Visibility' but for the export buttons.

    So you press the 'CSV' button, and a window appear to choose which columns you want to export besides what you selected with the 'Column Visibility' button.

    Thanks a lot!

    Jau

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    There isn't an option for that at the moment. You'd need to create a custom button that provides that ability if you need that.

    Allan

This discussion has been closed.