Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How to sum cells then apply number format?

$
0
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!


Viewing all articles
Browse latest Browse all 2364