How to round and a use two decimal places in group headers
How to round and a use two decimal places in group headers
thegamechangerpro
Posts: 81Questions: 30Answers: 1
This works fine but since it's currency, I want it to always have two decimal places (and round to those two decimals places).
var gross = rows
.data()
.pluck('gross')
.reduce( function (a, b) {
return a + b*1;
}, 0);
...then later
.append('<td colspan="1" style="text-align:right;">' + gross + '</td>')
.attr('data-name', groupAll)
.toggleClass('collapsed', collapsed);
I know how to do this in the colDefs and such, but that doesn't carry over into the groups
Answers
This SO thread has some options for rounding to two decimal places. Use the technique that meets your requirements with the
gross
variable.Kevin