I have solved this by using footer of datatable for performing sum of column of datatable
below is my jsp code:
<tfoot>
<tr>
<th colspan="8" style="text-align:right">Total:</th>
<td id="finTotal">${employee.finTotal}</td>
<td id="sumMonth1">${employee.sumMonth1}</td>
<td id="sumMonth2">${employee.sumMonth2}</td>
<td id="sumMonth3">${employee.sumMonth3}</td>
<td id="sumMonth4">${employee.sumMonth4}</td>
<td id="sumMonth5">${employee.sumMonth5}</td>
<td id="sumMonth6">${employee.sumMonth6}</td>
<td id="sumMonth7">${employee.sumMonth7}</td>
<td id="sumMonth8">${employee.sumMonth8}</td>
<td id="sumMonth9">${employee.sumMonth9}</td>
<td id="sumMonth10">${employee.sumMonth10}</td>
<td id="sumMonth11">${employee.sumMonth11}</td>
<td id="sumMonth12">${employee.sumMonth12}</td>
</tr>
And following is js code:
$('#tList1').dataTable({
"columnDefs": [
{"targets": 3,"width": "80px"},
{"targets": 4,"width": "100px"}
],
dom : 'lBfrtip',
buttons : [
/* 'excel', */
{
extend : 'excel',
text : 'Export File',
exportOptions : {
modifier : {
selected : null
}
}
}
],
select : null,
"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( 8, { search: 'applied'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 8 ).footer() ).html(
total
);
}
});