Buttons (copy, csv, etc..) don't show in my datatable

Buttons (copy, csv, etc..) don't show in my datatable

alfasino9alfasino9 Posts: 31Questions: 5Answers: 0

Hello,

I have tried to add to my DataTable the Buttons option to export, but they don't appear :(

You can view here the datatables -> http://comparador.masqueunaweb.com/buscador3.php

Thanks for any help.

Best regards

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    The browser's console shows this error:
    "buttons.dataTables.min.css:1 Uncaught SyntaxError: Unexpected token {"

    You have:

    <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
        </script>
    

    Since its not a JS script you will need to use something like this:

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
    

    Kevin

  • alfasino9alfasino9 Posts: 31Questions: 5Answers: 0

    Hello @kthorngren ! Nice to see you here :smiley: :

    I have changed your advice, but it doesn't work.

    Now that error is not shown but the buttons still not appears :(

    Thank you for your help as always!

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin
    Answer ✓

    You've got two Buttons arrays in the same DataTables configuration object:

                    buttons: [
                    'copy', 'csv', 'excel', 'pdf', 'print'
                    ],
    

    and then later:

                    buttons: [{
                extend: "selectedSingle",
                text: "Actualizar",
                action: function ( e, dt, node, config ) {
                   ...
            }
                    ]
    

    That's like having

    var i = 1;
    i = 2;
    

    and expecting i to be both 1 and 2. The second one will "win".

    You need to merge the two arrays together.

    Allan

  • alfasino9alfasino9 Posts: 31Questions: 5Answers: 0

    Thank you allan!

    And how we can organize this 5 buttons into only one with dropdown the 5?

    Thank you!

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin
    Answer ✓

    This example demonstrates how the collection button type can be used.

    Allan

  • alfasino9alfasino9 Posts: 31Questions: 5Answers: 0

    Thank you, don't see it !!

    Best regards

This discussion has been closed.