Add Delimiter to Sum Value in Footer

Add Delimiter to Sum Value in Footer

mcarlottamcarlotta Posts: 11Questions: 4Answers: 0
edited March 2014 in DataTables 1.10
First, thank you for the wonderful API update in the current version. I am utilizing the sum() feature and wondering if there is a way to add a delimiter to the footer total?

Right now, for example, I am seeing: 234567

Is there a way to have it displayed as: 234,567

Thanks.

[code]
$("#locations_list").DataTable footerCallback: (row, data, start, end, display) ->
api = @api()

# Remove the formatting to get integer data for summation
intVal = (i) ->
(if typeof i is "string" then i.replace(/[\$,]/g, "") * 1 else (if typeof i is "number" then i else 0))


# Total spots
spotTotal = api.column(5,
page: "current"
).data().reduce((a, b) ->
intVal(a) + intVal(b)
)

# Total dec
decTotal = api.column(6,
page: "current"
).data().reduce((a, b) ->
intVal(a) + intVal(b)
)

# Total dec
oohTotal = api.column(7,
page: "current"
).data().reduce((a, b) ->
intVal(a) + intVal(b)
)

# Update footer
$(api.column(5).footer()).html "" + spotTotal
$(api.column(6).footer()).html "" + decTotal
$(api.column(7).footer()).html "" + oohTotal
[/code]
This discussion has been closed.