sum all the contents of the columns
sum all the contents of the columns
Hello, how do I add all this and show it in a single row of the table? Is the column 4
The idea is to add them up and calculate the average, and that average that is shown in a single row, can you?
This discussion has been closed.
Replies
This does it in the footer but you'll find a way to insert a table row showing the same:
https://datatables.net/examples/advanced_init/footer_callback.html
Thanks, but it doesn't work for me, I need to show the average in a single row, that is, all added divided by the number of elements it has
just search the docs please!
e.g. for this: https://datatables.net/reference/api/count()
table.rows().count() counts the rows of your table
You'll find the rest as well by using the search field in the upper right hand corner ...
Ok thanks, but what I want is to add all the rows of the column and show it in one row, not the footer
You can use the
footerCallback
or if you prefer thedrawCallback
and do the same thing as the example rf1234 linked to. Instead of placing it in the footer you can update the row. You can userow().data()
orcell().data()
to update the desired row. You can use one of options of therow-selector
to select the row.If you need further help the best thing to do is build a simple example of what you have and provide specifics of how to choose the row to update.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks !