Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directly adding footer in JQuery DataTable

I want to directly add a footer to a JQuery datatable, just like I would for the body of the table using the dt.row.add() method. How is this possible without using the footer callback method?

Thanks.

like image 740
thomasdclark Avatar asked Sep 13 '26 23:09

thomasdclark


1 Answers

DataTables doesn't seem to have a API to add a footer dynamically, if that's what you want. It checks for presence of <tfoot> element during initialization only.

To add a footer dynamically:

  1. Destroy the table with destroy().

    $('#example').DataTable().destroy();
  2. Append <tfoot><tr><th></th></tr></tfoot> to the <table> element making sure you're adding as many <th></th> elements as there are columns in the table.

  3. Re-initialize the table with the same options:

    $('#example').DataTable({ /* your options here */ });
like image 171
Gyrocode.com Avatar answered Sep 15 '26 13:09

Gyrocode.com



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!