language.decimal and total Footer callback problem

language.decimal and total Footer callback problem

triple_6triple_6 Posts: 5Questions: 2Answers: 0

Hi,
I set in my table like in this topic: language.decimal decimal and thousands separator

$('#example').dataTable( {
  "language": {
    "decimal": ",",
    "thousands": ","
  }
} );

Ive got European number : 12.345.678,90

Now i want to use Footer callback total like in this example: Footer callback

Now how i can remove the formatting to get integer data for summation?
i dont know how i can change i.replace(/[\$,]/g, '')*1 for this case.

Thanks for any help!

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,813Questions: 1Answers: 10,516 Site admin
    edited August 2016 Answer ✓

    Strip the .s out and then replace the , with a . to get something Javascript will recognise as a number

    Allan

  • triple_6triple_6 Posts: 5Questions: 2Answers: 0
    edited August 2016

    Hi Allan,
    i change that for i.replace('.','').replace(/[\$,]/g, '.')*1
    that gives me properly number but only for "Total over this page". Look on this screen from example:

  • allanallan Posts: 63,813Questions: 1Answers: 10,516 Site admin

    I would need a link to a page showing the issue so it can be debugged please.

    Regarding the incorrect marking of my answer above as correct, unfortunately the forum doesn't have an option to undo that.

    Allan

  • triple_6triple_6 Posts: 5Questions: 2Answers: 0
    edited August 2016

    Link to sample : live.datatables.net

  • allanallan Posts: 63,813Questions: 1Answers: 10,516 Site admin
    Answer ✓

    I'm not sure I entirely understand the issue I'm afraid. Are you concerned about the repeating 9 in the floating point number? If so, use toFixed() to fix it - example.

    See this blog post if you want details on why that happens in Javascript (or most other languages).

    Allan

  • triple_6triple_6 Posts: 5Questions: 2Answers: 0

    Thanks, that is what i need! Works perfect!
    Thanks for Your help.

This discussion has been closed.