$(function(){ $("#datatables-1").dataTable(); var table = $('#datatables-2').DataTable(); $("#datatables-2 tfoot th").each( function ( i ) { var select = $('') .appendTo( $(this).empty() ) .on( 'change', function () { table.column( i ) .search( '^'+$(this).val()+'$', true, false ) .draw(); } ); table.column( i ).data().unique().sort().each( function ( d, j ) { select.append( '' ) } ); } ); $('#datatables-3').dataTable( { "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 data = api.column( 4 ).data(); total = data.length ? data.reduce( function (a, b) { return intVal(a) + intVal(b); } ) : 0; // Total over this page data = api.column( 4, { page: 'current'} ).data(); pageTotal = data.length ? data.reduce( function (a, b) { return intVal(a) + intVal(b); } ) : 0; // Update footer $( api.column( 4 ).footer() ).html( '$'+pageTotal +' ( $'+ total +' total)' ); } } ); $('#datatables-4').DataTable( { dom: 'T<"clear">lfrtip', tableTools: { "sSwfPath": "./assets/libs/jquery-datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf" } } ); })