Error Sum Table Footer
Error Sum Table Footer
rafasw
Posts: 78Questions: 7Answers: 0
hello i'm having trouble adding a footer with the total sum
My Full Code
$(document).ready(function() {
var advance = $('#advanced-table').DataTable( {
dom: 'Blfrtip',
mark: true,
buttons: {
name: 'primary',
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ]
},
//"language": {
//"url": "http://cdn.datatables.net/plug-ins/1.10.13/i18n/Portuguese-Brasil.json"
// }
"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( 5 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column( 5, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 5 ).footer() ).html(
'R$'+pageTotal +' ( R$'+ total +' Value Total)'
);
}
} );
// Setup - add a text input to each footer cell
$('#advanced-table tfoot th').each( function () {
} );
// Apply the search
advance.columns().every( function () {
var title = $(this.footer()).text();
$(this.footer()).html( '<div class="md-input-wrapper"><input type="text" class="md-form-control" placeholder=" '+title+'" /></div>' );
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that.search( this.value ).draw();
}
} );
} );
} );
Error Image
using my code how can I put everything below this image
thanks
This discussion has been closed.
Replies
Do yu have a
tfoot
tag in your HTML table when you initialize Datatables? If not you will need to add one. If you still have problems please post a link to your page or a test case so we can see what is happening.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin