Is it possible to sum the datas from a filtered column?

Is it possible to sum the datas from a filtered column?

autoexecautoexec Posts: 3Questions: 0Answers: 0
edited June 2013 in General
Hi,
I would like to know how it is possible to get a sum of a filtered column?
For example I have 300 datas after filtering there are only 30 and I would like to have the sum of those 30 datas.
If its not filtered it should show the sum of all 300 datas.
Can someone help me with the code?

Replies

  • autoexecautoexec Posts: 3Questions: 0Answers: 0
    I found this here: http://datatables.net/forums/discussion/2053/fnfootercallback-sum-column-after-filter/p1#Form_Comment
    but I'm not sure how to implement the code [code]$('#example').dataTable()._('td:nth-child(4)', {"filter": "applied"})[/code] in this code: [code]$(document).ready(function() {
    $('#example').dataTable( {
    "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
    /*
    * Calculate the total market share for all browsers in this table (ie inc. outside
    * the pagination)
    */
    var iTotalMarket = 0;
    for ( var i=0 ; i
  • autoexecautoexec Posts: 3Questions: 0Answers: 0
    Thank you for no help!
    I solved the problem by myself...

    [code]
    "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {

    var oTable1 = $('#example').dataTable();
    var oTable2 = $('#example').dataTable();

    var data = oTable1._('td:nth-child(5)', {"filter": "applied"});
    var data2 = oTable2._('td:nth-child(4)', {"filter": "applied"});

    var summe = 0;
    var summe2 = 0;
    for ( var i = 0; i
  • nullonenullone Posts: 2Questions: 0Answers: 0
    Thanks for posting your response, this did help me as I was trying to sum filtered columns. Unfortunately, this does not work with hidden columns. Still digging for a solution.
This discussion has been closed.