Footer Callback - calculate sum - not percentage
Footer Callback - calculate sum - not percentage
thomas1956
Posts: 4Questions: 0Answers: 0
I have some trouble with the footer callback example. Maybe (it must be) it's me not being too clever in javascript - so please give me a hint:
I have a table with numeric columns (two) that are populated with numbers (one decimal - "," as seperator) and I want to calculate the sum (in the footer) of these values. If the user filter the data it must calculate the sum of the filtered dataset.
Actually the example on datatables.net is what I am trying to do - just calculate sum - not percentage.
/ thomas
I have a table with numeric columns (two) that are populated with numbers (one decimal - "," as seperator) and I want to calculate the sum (in the footer) of these values. If the user filter the data it must calculate the sum of the filtered dataset.
Actually the example on datatables.net is what I am trying to do - just calculate sum - not percentage.
/ thomas
This discussion has been closed.
Replies
Firstly, are you using a comma as the 10^3 separator (e.g. 5,000)? If so you will need to strip this out (.replace(/,/g, "") would do) before you can do any calculations in Javascript since it's not a valid Javascript number. From there, the total should be very similar to my example code, just without calculating the percentage :-)
Regards,
Allan