more code

more code

olivier74olivier74 Posts: 3Questions: 1Answers: 0

I am using multiple scripting (Footer callback, File export) on the same table, but I have an error message "Cannot reinitialise DataTable" I do not know how to remedy this problem.

Thank you

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    I would suggest reading over the documentation page that the error links to. If that doesn't help, then, per the forum rules, please link to a test case.

    Allan

  • olivier74olivier74 Posts: 3Questions: 1Answers: 0

    Hello ,
    the error messages are missing,
    but against certain functions disappear footer Calback does not work, this is a css problem?

    $(document).ready(function(){
                $('#tarif').DataTable( {
                    language: {
                        "sProcessing":     "Traitement ...",
                        "sSearch":         "Rechercher :",
                        "sLengthMenu":     "Afficher _MENU_ éléments",
                        "sInfo":           "_START_ à _END_ / _TOTAL_ ",
                        "sInfoEmpty":      "0 à 0 sur 0 éléments",
                        "sInfoFiltered":   "(filtré de _MAX_ éléments au total)",
                        "sInfoPostFix":    "",
                        "sLoadingRecords": "Chargement en cours...",
                        "sZeroRecords":    "Aucun élément à afficher",
                        "sEmptyTable":     "Aucune donnée disponible dans le tableau",
                        "oPaginate": {
                            "sFirst":      "Premier",
                            "sPrevious":   "Précédent",
                            "sNext":       "Suivant",
                            "sLast":       "Dernier"
                        },
                        "oAria": {
                            "sSortAscending":  ": activer pour trier la colonne par ordre croissant",
                            "sSortDescending": ": activer pour trier la colonne par ordre décroissant"
                        }
                    },
                   "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "Tout"] ],
                    
                    dom: 'Bfrtip',
                    buttons: [
                        'copy', 'csv', 'excel', 'pdf', 'print'
                    ]
                         
                 
            
                 });
            "footerCallback": function ( row, data, start, end, display ) {
                var api = this.api(), data;
     
                // Remove the formatting to get integer data for summation
                var intVal = function ( i ) {
                    return typeof i === 'string' ?
                        i.replace(/[\$,]/g, '')*1 :
                        typeof i === 'number' ?
                            i : 0;
                };
     
                // Total over all pages
                total = api
                    .column( 4 )
                    .data()
                    .reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    }, 0 );
     
                // Total over this page
                pageTotal = api
                    .column( 4, { page: 'current'} )
                    .data()
                    .reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    }, 0 );
     
                // Update footer
                $( api.column( 4 ).footer() ).html(
                    '$'+pageTotal +' ( $'+ total +' total)'
                );
            }
        } );
    } );
    

    thanks for your help

    Merci

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    We'd need a link to the page as I requested above. Use JSFiddle or http://live.datatables.net to create a test case if you can't link to your page.

    Allan

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    I'm getting a syntax error when trying to run that example I'm afraid.

    Allan

This discussion has been closed.