language.decimal and total Footer callback problem
language.decimal and total Footer callback problem
triple_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:
This discussion has been closed.
Answers
Strip the
.
s out and then replace the,
with a.
to get something Javascript will recognise as a numberAllan
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:
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
Link to sample : live.datatables.net
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, usetoFixed()
to fix it - example.See this blog post if you want details on why that happens in Javascript (or most other languages).
Allan
Thanks, that is what i need! Works perfect!
Thanks for Your help.