Number field formatting with commas and parentheses
Number field formatting with commas and parentheses
CT General Assembly
Posts: 20Questions: 3Answers: 1
in Editor
We have number fields that we are allowing inline editing of. The render we are using is as follows:
render: $.fn.dataTable.render.number(',', '.', 0, '')
If the user types 100,200 for some reason, the number is truncated down to 100.
Also, we want them to be able to type(1000) and have that be equal to -1000.
Any suggestions?
This discussion has been closed.
Replies
I am wondering if the problem is elsewhere. I am using it up to a billion with no issue.
That is correct and expected for that rendering function. It expects the number to be passed in as a "real" number, not a formatted one (i.e. one which Javascript understands as a number - with a dot decimal place).
You would need a custom renderer to do what you are looking for here, and also for the negatives (allow either to be input, output only one style).
Allan
In retrospect, I took a different approach. In the preSubmit, I'm converting the formatted number back to a "real" number. This seems to do the trick. Thanks for the replies. Just thinking about it after I read them allowed me to take a new route and now it is working as I hoped.
Lol, so mine worked accidently because I created a field type plug-in that returns a real number.