How to sum cells then apply number format?
How to sum cells then apply number format?
monkeyboy
Posts: 60Questions: 19Answers: 0
I am adding up some cells to get a row total. I do understand how to combine your render.number to that result:
columns: [
{ data: "myTable.Some Money", "sClass": "binCentered",
render: $.fn.dataTable.render.number( ",", ".", 0, "$" )
},
{
data: null,
className: "sum",
render: function(data, type, row) {
return parseInt(data.myTable.jan) + parseInt(data.myTable.feb) + parseInt(data.myTable.mar)
+ parseInt(data.myTable.apr) + parseInt(data.myTable.may) + parseInt(data.myTable.jun)
+ parseInt(data.myTable.jul) + parseInt(data.myTable.aug) + parseInt(data.myTable.sep)
+ parseInt(data.myTable.oct) + parseInt(data.myTable.nov) + parseInt(data.myTable.december);
}
},
.
.
.
.
]
As you can see I user number.render to format money with a dollar sign, and commas.
How can in include this withing my render function which sums my monthly cash?
Thanks for the help!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Do this:
where
sum
is the summation value.Allan
Alan,
As always - you ROCK!