how to Dynamically update footer with total, min and Average of datatable columns
how to Dynamically update footer with total, min and Average of datatable columns
Samk
Posts: 6Questions: 2Answers: 0
Link to test case: https://live.datatables.net/zalitado/3/edit
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: unable to dynamically update totals in footer as the input text changes in the columns. and looking for a function to generate average and min of columns.
This question has accepted answers - jump to:
Answers
You need to keep up with the input value by updating it when changed by updating the document. And you need to have Datatables updates its data cache to know about the change using
cell().invalidate()
. Last you will need to usedraw()
, with thepage
parameter to stay on the same page, to havefooterCallback
to run. See updated example:https://live.datatables.net/zalitado/5/edit
Kevin
thanks very much Kevin, oddly the column 3 doesn't update, although the data type is converted to numeric. is the column somehow being set to string after the redraw, seem unlikely though
You can use the v2 multi-row header / footer API to be able to pick out and update the other rows in the footer: https://live.datatables.net/zalitado/10/edit .
I've used plug-in API methods for average and min there as well.
The data type issue doesn't appear to effect funcationlity?
Allan
thanks allan, giant leap!!
. ive made some changes to compensate for zero values when calc'ing average and min values. im now stuck with a search or vlookup type behaviour that that i need to populate the cpty with the min, max, and average values that have been calc'd. testcase -> https://live.datatables.net/zalitado/13/edit
I've added a reply to your other thread on that topic.
Allan