Created
April 17, 2020 15:29
-
-
Save reachkamrul/bcacf02720857404ea2c5d92e5257e83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Count Footer with fix | |
function myCustomFunction() { | |
var sum = 0; | |
var counts = 0; | |
$(".totals").each(function() { | |
var val = $.trim( $(this).text() ); | |
if ( val ) { | |
val = parseFloat( val.replace( /^\$/, "" ) ); | |
sum += !isNaN( val ) ? val : 0; | |
} | |
}); | |
$(".footable tbody tr:first-child td").each(function() { | |
counts++; | |
}); | |
if(!jQuery('table').find('tfoot').length){ | |
jQuery("<tfoot></tfoot>").appendTo(jQuery('table')); | |
} | |
jQuery("<tr class='final_result'><td colspan='"+counts+"'style='text-align: right'></td></tr>").prependTo(jQuery('table').find('tfoot')); | |
jQuery('table').find('tfoot .final_result td').html('Total of the column: ' + sum ); | |
} | |
myCustomFunction(); | |
$table.on('after.ft.paging', function () { | |
jQuery('.final_result').remove(); | |
myCustomFunction(); | |
}); | |
$table.on("after.ft.filtering", function () { | |
jQuery('.final_result').remove(); | |
myCustomFunction(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment