How can I use the sum() plugin only on filtered data?

How can I use the sum() plugin only on filtered data?

veryacaveryaca Posts: 11Questions: 4Answers: 0
edited December 2018 in Free community support

This plugin is great: https://datatables.net/plug-ins/api/sum().

However, it seems to sum the entire column when I use it this way:
table.column( 2 ).data().sum();

Anyone knows how I can achieve this?

This question has an accepted answers - jump to answer

Answers

  • veryacaveryaca Posts: 11Questions: 4Answers: 0

    I found a way to do it, but I'd like to confirm it's the right way to do it:

    table.column( 2, {filter:'applied'}).data().sum();

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @veryaca ,

    Yep, see this example here,

    Cheers,

    Colin

This discussion has been closed.