You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
$(function(){
|
|
$("#datatables-1").dataTable();
|
|
|
|
var table = $('#datatables-2').DataTable();
|
|
|
|
$("#datatables-2 tfoot th").each( function ( i ) {
|
|
var select = $('<select class="form-control input-sm"><option value=""></option></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( '<option value="'+d+'">'+d+'</option>' )
|
|
} );
|
|
} );
|
|
|
|
$('#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"
|
|
}
|
|
} );
|
|
}) |