DataTables with column rendering - Sum of two or more columns
DataTables with column rendering - Sum of two or more columns
Hello all,
I'm using mRender to combine the contents of two cells and then hiding the second cell as in http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html. It works fine for me.
Now, I'm wondering if it is possible to store the sum of two or more columns into another column say sum of col1 to col7 into col8.
If yes, then how?
Any help is highly appreciated.
PS : I've already used fnFooterCallback() to add sum of rows in footer, but not able to use that in above context.
I'm using mRender to combine the contents of two cells and then hiding the second cell as in http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html. It works fine for me.
Now, I'm wondering if it is possible to store the sum of two or more columns into another column say sum of col1 to col7 into col8.
If yes, then how?
Any help is highly appreciated.
PS : I've already used fnFooterCallback() to add sum of rows in footer, but not able to use that in above context.
This discussion has been closed.
Replies
Allan
Thanks for the help.
But, above method is producing concatenation result instead of sum.
Link to example:
http://live.datatables.net/agexap
Also, I'm trying to store the result of 4 sub-totals in the last column: Cumulative Total, but no luck here also.
Pls help where I'm doing it wrong. Thanks in advance.
Here is updated code:
http://live.datatables.net/etisag
Just a quick note:
> But, above method is producing concatenation result instead of sum.
Then you probably would need to add `parseFloat` or `parseInt` as needed.
Allan
Thank you for your post and help.
I tried that too earlier. But, (may be) because some of the columns are empty in the table, parseInt was producing NaN, as you can see it in the test case:
http://live.datatables.net/oleyob