Fixed Header and Buttons Extensions

Fixed Header and Buttons Extensions

mrpaulymrpauly Posts: 2Questions: 0Answers: 0

Can I create a datatable using fixedheader and buttons extensions all on same table. I seem to lose the fixedheader once I add the button. If ran individually, one of the extensions work or the other but not both at same time.

Replies

  • WindexWindex Posts: 1Questions: 0Answers: 0

    I was having this problem too, this might be 'hacky' but this is how I got around it:

    $(document).ready(function() {
      var table = $('.table').DataTable( {
         "lengthMenu": [[100, 1000, 5000, -1], [100, 1000, 5000, "All"]],
         dom: 'Bfrtip',
         buttons: [
           'copy', 'excel', 'pdf', 'csv'
         ],
         fixedHeader: true
       } );
       new $.fn.dataTable.FixedHeader( table, {
         alwaysCloneTop: true
       } );
    } );
    
  • ewilesewiles Posts: 1Questions: 0Answers: 0

    I ran into this too. There is code in fixedheader that specifically disables it when buttons are configured. This despite the fact that the compatibility table shows that both Buttons ColVis and FixedHeader are supposed to be compatible.

This discussion has been closed.