I have a process that is calling out to another AJAX process to do a bunch of calculations, which takes the result of that and updates the text boxes on the screen using the pui.set() API.
The only issue I am having is that the fields lose all of their formatting after this. I have the fields setup to be displayed as number, with the Use 1000 Separator checked. So before the call, it will display as 100,000.00 and after I run my pui.set() i get 100000.00.
Do I need to run some sort of applyProperty() on each field to reset that formatting?
field formatting after AJAX request
-
- Profound User
- Posts: 27
- Joined: Fri Oct 23, 2015 9:51 am
- First Name: Ken
- Last Name: Swisher
- Company Name: MHC
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: field formatting after AJAX request
pui.set() does not re-format the number, it uses whatever format you've given. So you'll want to preformat it before calling pui.set().
An easy way to do that if you are using a modern, up-to-date, browser is like this:
toFixed(2) formats it with 2 decimal places
toLocaleString() adds commas or periods as decimal separators, based on the browser's locale settings.
toLocaleString() does require an up-to-date browser. It will not work on IE10, for example. There is more information here:
https://developer.mozilla.org/en-US/doc ... caleString
Of course, you can use any sort of string/number operations you like to do the formatting. Google number formatting in JavaScript for lots of examples... toLocaleString() is just an example that works nicely for me.
An easy way to do that if you are using a modern, up-to-date, browser is like this:
Code: Select all
pui.set("yourField", Number(100000).toFixed(2).toLocaleString());
toLocaleString() adds commas or periods as decimal separators, based on the browser's locale settings.
toLocaleString() does require an up-to-date browser. It will not work on IE10, for example. There is more information here:
https://developer.mozilla.org/en-US/doc ... caleString
Of course, you can use any sort of string/number operations you like to do the formatting. Google number formatting in JavaScript for lots of examples... toLocaleString() is just an example that works nicely for me.
Who is online
Users browsing this forum: No registered users and 1 guest