[Filtering] Get the total of one column in real time

[Filtering] Get the total of one column in real time

ZirionZirion Posts: 5Questions: 2Answers: 0

Hello world,

I've built a table with datatable, and included the Filtering plug-in.
Among the informations of each row is a number of hours spent.
The question is : How can I calculate the total amount of hours in real time (So while using the Filtering plug-in) ?

Thx in advance,
Zirion

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    How can I calculate the total amount of hours in real time (So while using the Filtering plug-in) ?

    Where and how are you trying to use this?

    You can use selector-modifier of {search: 'applied} with rows(), column() or cell() APIs to get the filtered data set. For further help please provide a test case showing what you are trying to do so we can provide more specific help.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • ZirionZirion Posts: 5Questions: 2Answers: 0

    On the same page, I want to display the sum of the "Heures" column, considering the search bar's results, and I can't really see how selector-modifier could help me with that...

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948
    Answer ✓

    Take a look at the Footer Callback example. It shows how to sum just the page. You can do the same but change it to {search: 'applied}. If you still need help please provide a running test case so we can help update your code.

    Kevin

  • ZirionZirion Posts: 5Questions: 2Answers: 0

    Thank you,
    The Footer Callback Example helped me a lot, I just modified some parameters and set my input as "number" instead of "test", and by now my result is shown.

This discussion has been closed.