Unable to display buttons

Unable to display buttons

cyrakusecyrakuse Posts: 1Questions: 1Answers: 0

I try to add buttons for excel and pdf export but i'm unable to display them
i miss something but i can't find where is my mistake.

Here is my code :

<link href="includes/js/datatables/v2/datatables.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="includes/js/datatables/v2/datatables.min.js"></script>
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/buttons.bootstrap.min.js"></script>
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/buttons.html5.min.js"></script>
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/buttons.print.min.js"></script>
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/buttons.colVis.min.js"></script>
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/buttons.jqueryui.min.js"></script>
    
    <script type="text/javascript" src="includes/js/datatables/v2/Buttons-1.2.4/js/dataTables.buttons.min.js"></script>

<table  id="myList" cellpadding="0" cellspacing="0" width="100%">
                            <thead>
                                <tr>
                                    <th>field 1</th>
                                    <th>field 2</th> 
                                    <th>field 3</th>
                                    <th>field 4</th>
                                </tr>
                            </thead>
                            <tbody>
                                     <tr>
                                            <td>value 1</td>
                                            <td>value 2</td>
                                            <td>value 3</td>
                                            <td>value 4</td>
                                     </tr>                     
                            </tbody>
                        </table>
<script>
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
            "date-uk-pre": function ( a ) {
                var ukDatea = a.split('/');
                return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
            },

            "date-uk-asc": function ( a, b ) {
                return ((a < b) ? -1 : ((a > b) ? 1 : 0));
            },

            "date-uk-desc": function ( a, b ) {
                return ((a < b) ? 1 : ((a > b) ? -1 : 0));
            }
        } )

 var myTab= $("#myList").dataTable(   
                {
                    "iDisplayLength": 50,
                    "aLengthMenu": [5,10,25,50,100], 
                    "sPaginationType": "full_numbers",
                    'aoColumnDefs': [
                        { 
                            'bSortable': true, 
                            "sType": "date-uk", 
                            'aTargets': [ 2 ] 
                        }
                    ],                                       
                    "oLanguage": {
                        "sLengthMenu": "Voir _MENU_ lignes",
                        "sZeroRecords": "Aucune donnée correspondante",
                        "sInfo": "Lignes _START_ à _END_ sur _TOTAL_ lignes au total",
                        "sInfoEmpty": "Lignes 0 à 0 sur 0 lignes au total",
                        "sInfoFiltered": "(filtré depuis _MAX_ lignes au total)",
                        "oPaginate": {
                            "sFirst": "|<",
                            "sLast": ">|",
                            "sNext": ">>",
                            "sPrevious": "<<"
                        },
                        "sEmptyTable": "Aucune données",
                        "sSearch": "Chercher:"
                    },
                    "sDom": 'T<"clear">lfrtip',
                    buttons: [
                        'copy', 'csv', 'excel', 'pdf', 'print'
                    ],
                });


        myTab.buttons().container().insertBefore( '#myList' ); 

I obtain this error : "TypeError: myTab.buttons is not a function"

Someone can help me ?

Answers

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin

    Don't use T, use B in the dom option for Buttons. See this example.

    The T option was the old TableTools software.

    Allan

This discussion has been closed.