Footer not created in dom
Footer not created in dom
Hi,
I'm trying to create a table footer with totals, similar to the example shown here:
https://datatables.net/reference/api/columns().footer()
Minor comment: the example is missing a second arg of 0 to reduce()
Debugging shows the sum is correctly calculated, but insertion into the dom fails:
$( this.footer() ).html( 'Sum: '+sum );
because there is no tfoot
tag (the first arg of footerCallback
is also empty). Documentation of dom
does not mention if a letter needs to be supplied to create a footer, and column.footer()
and columns.footer()
are only getters - ie cannot be used to create a footer row.
I have managed to make it work by manually inserting <tfoot></tfoot>
tags into the html and injecting $('tfoot').html('<tr><td> ....')
but this is surely not intended. I also need to 'manually' create the right number of cells ...
How should the footer be created?
PS fixedHeaders is in use, but set to false on the page in question.
DataTables 1.10.10.
Answers
Ok - just saw this:
https://datatables.net/forums/discussion/27829/add-table-footer-with-javascript-only
"You need to add the footer before you create the table as DataTables doesn't provide a method for creating a footer at the moment."
And when I do exactly that, I see
this.footer()
working as expected. So the footer shpild not be created infooterCallback
, just populated with data there.Yes this is currently the correct way of doing it.
Thanks for posting back,
Tom