Excel and PDF buttons not showing up on DataTable

Excel and PDF buttons not showing up on DataTable

theodikustheodikus Posts: 25Questions: 10Answers: 0

I'm importing the following into my page:

import 'jquery';
import '../../DataTables-1.10.11/js/jquery.dataTables';
import '../../JSZip-2.5.0/jszip';
import '../../Buttons-1.1.2/js/dataTables.buttons';
import '../../Buttons-1.1.2/js/buttons.html5';
import '../../Buttons-1.1.2/js/buttons.print';

and here is my table:

$('#a-table').DataTable({
            "buttons": [
                'copy', 'excel', 'pdf'
            ],
            "columns": [
                    // request_by
                { "width": "8%" }, 
                { "width": "8%" }, 
                { "width": "15%" }, 
                { "width": "8%" },
                { "width": "5%" },
                { "width": "15%" }, 
                { "width": "5%" },
                { "width": "36%" } 

              ],
             buttons: true,
            "stateSave": false,
            "pageLength": -1,
            "data": this.tableArray,
            "oLanguage": {
                "sSearch": "Search table for: ",
                "sEmptyTable": "You haven't searched for anything yet."
              },
             "dom": 'Bfrtip'

        
        });

Instead of seeing copy, excel, and pdf butons, I'm seeing Copy, CSV, and Print. Any idea why?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,106Questions: 1Answers: 10,394 Site admin
    Answer ✓

    That looks okay to me. Can you link to the page in question so I can debug it please.

    Allan

  • theodikustheodikus Posts: 25Questions: 10Answers: 0

    I had to move the source scripts into the main src directory. Aurelia is finicky. lol Thanks for your help though.

  • leflefleflef Posts: 2Questions: 0Answers: 0

    Got the same problem, found that is was related to the order of the scripts. I was not able to fix it with the import statements ordering, needed to manually add it at the top of the file.

    It might have been an idea to add a warning in case jszip was not present when adding the 'excel' option to buttons.

  • allanallan Posts: 63,106Questions: 1Answers: 10,394 Site admin

    It might have been an idea to add a warning in case jszip was not present when adding the 'excel' option to buttons.

    I take that point and can see the reasoning for it. However, it is also valid to have included the Excel button and not JSZip, and having a warning for that would be really frustrating.

    However, this is something that needs to be thought about a bit more, since it is tripped a few people up.

    Thanks!

    Allan

This discussion has been closed.