Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81728

Override default button export options?

$
0
0

Almost all my datatables have the last two columns that I don't want to print etc. I did this:

    $.extend($.fn.dataTable.defaults, {
      buttons: {
        buttons: [
          {
            extend: 'print',
            exportOptions: {
              columns: [':lt(-2)']
            }
          }
        ]
      }
    });

I have a default call on a class that loads the datatable.

Now I have the odd table that I want to clear this and print all columns. So I clear that class and manually initialize:

$('#odd_table').dataTable({
  buttons: {
    buttons: [
      {
        extend: 'print',
        text: '<i class="far fa-print"></i> Print',
        orientation: 'landscape',
        exportOptions: {
          columns: [0, 1]
        }
      }
    ]
  }
});

No mater what I specify in the exportOptions the default options are applied. I figured this was as easy as changing the default settings.


Viewing all articles
Browse latest Browse all 81728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>