Column summed to footer no longer recalculating when searching

Column summed to footer no longer recalculating when searching

cj1005cj1005 Posts: 142Questions: 45Answers: 1

Link to test case:
https://www.wd4g.com/WCGateway/Test.wc

Description of problem:
The 'Amount' column is summed in the footer correctly, but if you do a search for some data, the footer total is no longer recalculating based on the search result.

My row call back code is as follows:

footerCallback: function( tfoot, data, start, end, display ) {
    var api = this.api();
    api.columns( 1 ).every(function() {
      var sum4 = this
       .data()
       .reduce(function(a, b) {
        var x = parseFloat(a) || 0;
        var y = parseFloat(b) || 0;
        return x + y;
      }, 0);
      $( api.column(1).footer() ).html('£'+(Math.round(sum4 * 100) / 100));
    });
  }

This was working until recently, so I've obviously messed something up, but I'm struggling to find the cause, could someone kindly take a look and see what might be causing this?

Thanks, Chris

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    See this example for how to sum the column based on the filtered rows. Use the selector-modifier of {search: "applied"} to sum based on the search result.

    Kevin

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Thank you Kevin, that has fixed my issue.

Sign In or Register to comment.