i am very new in java. i am trying to display total in footer but can`t. and trying to total sum wi
i am very new in java. i am trying to display total in footer but can`t. and trying to total sum wi
azizulkhn
Posts: 1Questions: 1Answers: 0
<script type="text/javascript">
$( document ).ready(function() {
$('#employee_grid').DataTable({
"processing": true,
"sAjaxSource":"response.php",
"dom": 'lBfrtip',
"buttons": [
{
extend: 'collection',
text: 'Export',
buttons: [
// 'copy',
// 'excel',
// 'csv',
'pdf',
// 'print'
]
}
]
"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api(), data;
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
var amtTotal = api
.column( 5 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$(tfoot).find('th').eq(1).html(amtTotal );
},
} );
} );
</script>
EDIT: Updated to use Mardown code formatting
This discussion has been closed.
Answers
I don't see anything that stands out as an issue. Can you post a link to your page or a test case showing the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Please describe what happens. Looks like you are trying to display the total in the header not the footer. Looks like you are basing your code off this example:
https://datatables.net/examples/advanced_init/footer_callback.html
Between line 35 and 36 in the above use
console.log(amtTotal);
, what do you see as the result?Kevin