How to include commas as per currency format in the Totals ie footer

How to include commas as per currency format in the Totals ie footer

rocky2016rocky2016 Posts: 11Questions: 6Answers: 0

I'm using Datatable api to calculate and display sum(total) in the footer. But how can I format it to curreny and commas.
{{total | currency:'USD':true:'1.2-2'}}, I cant use this as I'll be using api $( api.column( 1 ).footer() ).html(
'$'+total
);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    You need to render it yourself. You can actually use the built in renderer to do it:

    var formatted = $.fn.dataTable.render.number( ... ).display( numberToRender );
    

    Allan

  • rocky2016rocky2016 Posts: 11Questions: 6Answers: 0
    edited September 2016

    This worked exactly,
    $.fn.dataTable.render.number(',','.','2','$').display(total)

This discussion has been closed.