How to summarize multiple columns
How to summarize multiple columns

I have the code on this page working:
https://datatables.net/examples/advanced_init/footer_callback.html
However I don't understand how to summarize multiple columns, the example just summarizes one. I have a table where I want to summarize 3 columns and average a final column. How is that accomplished?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The function you have copied refers to "column( 4 )" throughout. You could rewrite it to accept a variable column number as a passed parameter.
Yes, I understand that it uses column(4) throughout. My javascript skills are not good enough to know how to make that a dynamic variable which is why I needed help with that snippet.
But anyhow I solved this issue a different way:
First use the SUM Plugin Declare it before the datatable initialization but inside document ready block:
Now the footer callback inside the datatable definition looks like this:
That's perfect and exactly what tangerine was suggesting.
Nice one
Allan