Unable to display buttons

Unable to display buttons

CenterFoundCenterFound Posts: 30Questions: 10Answers: 0

Attempting to use the Buttons extension, and not able to display the buttons, as per the documentation.
I've tried each of the methods, yet they are not showing.
Can you review my js on http://live.datatables.net/sojeluju/1/
Help show me what I'm missing.

$(document).ready( function () {
var table = $('#example').DataTable({
"sPaginationType" : "full_numbers",
"ajax": "/examples/server_side/scripts/server_processing.php",
"processing" : true,
"serverSide" : true,
"fixedHeader" : true,
"lengthMenu" : [[10, 25, 50, 100, 200, -1],[10,25,50,100, 200, "All"]],
"pageLength" : 25,
"sScrollX" : "110%",
"sScrollY" : "600px",
"bScrollCollapse": true,
"columnDefs": [
{ "type": "signed-num", "targets": 3}
],
dom: 'Bfrtip',
buttons: ['copy','excel','print']
});

        $('#example tfoot th').each(function() {
           var title = $('#example thead th').eq($(this).index()).text();
           console.log(title);
           $(this).html('<input type="text" placeholder="Search ' + title + '"/>');
       });
       table.columns().every(function () {
           var datatableColumn = this;
           $(this.footer()).find('input').on('keyup change', function() {
               datatableColumn.search(this.value).draw();
           });
       });                                           

} );

Thank you,
Allan

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    Sort out your js loading sequence. jQuery first, then DataTables, then DataTables' Buttons.

  • CenterFoundCenterFound Posts: 30Questions: 10Answers: 0

    Thanks, I didn't check this in the example. However, it didn't make a difference.

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    Try adding these scripts:

        <script src="https:////cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.2.4/js/buttons.html5.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.2.4/js/buttons.print.min.js"></script>
    

    Kevin

  • CenterFoundCenterFound Posts: 30Questions: 10Answers: 0

    Still encountering issues getting the buttons to display. I'm certain I'm doing something incorrectly. I'll go back over the docs and my code.

    Allan

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    I'd suggest using the download builder to make sure you get all the right files and in the right order.

    Allan

  • CenterFoundCenterFound Posts: 30Questions: 10Answers: 0

    Thank you

This discussion has been closed.