How to calcualte total for column if I use filter?

How to calcualte total for column if I use filter?

GhostKUGhostKU Posts: 3Questions: 1Answers: 0
edited December 2017 in Free community support

I have a table, and I have a filtetration for it Like:

this.api().column(4).search(_some_filtration_).draw();

And I want to get total sum in footer, So I took code from example:

total_util = this.api.column(4).data().reduce( function (a, b) {return a + b}, 0 );
console.log(total_util)

But it will always give me the value without using any filter :(

Answers

  • GhostKUGhostKU Posts: 3Questions: 1Answers: 0

    It looks like I need to use modifier option for .column() because

    Option used to specify how the content's of the selected columns should be ordered, and if paging or filtering in the table should be taken into account.

    But I don;t know how to use it.

  • GhostKUGhostKU Posts: 3Questions: 1Answers: 0

    I got it. I should use
    api.column(4, {'search': 'applied'}).data().reduce( function (a, b) {return a + b}, 0 );

  • vinishavinisha Posts: 1Questions: 0Answers: 0

    can i get full code of this method

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @vinisha ,

    If you combine @GhostKU 's final comment above, with this example here, you should be good to go,

    Cheers,

    Colin

This discussion has been closed.