Sumation of formatted values in rows/columns

Sumation of formatted values in rows/columns

UweBraunUweBraun Posts: 1Questions: 1Answers: 0
edited February 2022 in General

I am using below code to sum up values in a datatable. This works perfectly fine, as long as the value in the column is without formatting or any other content, like labels.
I have removed everything from the column now, but would need to format the column-cell like this:

<td style="font-weight: bold; text-align: right;">
@String.Format("{0:N0}", @Math.Round((item.KgPerHour * 24 * 365) / 1000))
</td>

But the "@String.Format..." prevents the summation as shown below. Is there a solution, a workaround?

Thank you very much.

"paging": true,
"autoWidth": true,
"footerCallback": function (row, data, start, end, display) {
var api = this.api();
nb_cols = api.columns().nodes().length;
var j = 7;
var numFormat = $.fn.dataTable.render.number('\,', '.', 0, '').display;
while (j < nb_cols) {
var pageTotal = api
.column(j, { search: 'applied' })
.data()
.reduce(function (a, b) {
return Number(a) + Number(b);
}, 0);

                $(api.column(j).footer()).html(numFormat(pageTotal));
                j++;
            }
        },

Answers

Sign In or Register to comment.