render.number() negative numbers format
render.number() negative numbers format
Hi there,
I've been using the datatables render function to format currencies recently: render: $.fn.dataTable.render.number( '.', ',', 2, '€ ' )
It works like a charm! It looks good and it sorts correctly. I'm very happy with it.
But I've noticed negative numbers are formatted like -€ 2,00 which feels strange to me. I'd like to change it to: € -2,00
How can I do this?
I've tried doing it like: render: function(data, type, row){ return '€ '+data; } but then my data doesn't sort correctly anymore.
Thanks in advance,
Gloria
This question has an accepted answers - jump to answer
Answers
Hi @pcsintjanbaptist ,
Yep, I don't think you'd get the existing renderer, you would need to modify the code to get it doing that.
The reason why
columns.render
wasn't working was because the sort couldn't work on that string. You can split it out so that the order returns the number, and the display does what you want, something like this.Hope that helps,
Cheers,
Colin