Footer callback with multiple columns
Footer callback with multiple columns
rudeigerc
Posts: 4Questions: 1Answers: 0
I've read the example of footer callback which calculates the total of one specific column.
Now suppose my table has two columns: quantity and price, how could I calculate the sum of (quantity times price) according to the api? I have noticed that the reduce function could not work on multiple columns. Thank you!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are your numbers static? If so, I would apply the row multiplication before you display (creating another column) the table, then you can use the summing in the callback that you are referring to.
Hi bindrid, thank you for answering the question. Actually, I'm using DataTables to show the schema in the database, and maybe an extra column shown in the table is not a good option.
So basically yes. In that case, it would actually be faster to do the calculations on the raw data before pushing into the table.
I did make this which might be of help
http://jsbin.com/putiyep/edit?js,output
Thank you very much, bindrid. I would take a look at the link!
@bindrid Finally I add a column to multiply the sum and set it as invisible, thanks a lot!