numerice (15,0) but want to display as (15,2)

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
jflummer
New User
Posts: 9
Joined: Tue May 28, 2019 11:38 am
First Name: jacqueline
Last Name: flummer
Company Name: CSS industries
Address 1: 2 whistler hill lane
City: huntington
State / Province: New York
Zip / Postal Code: 11743
Country: United States
Contact:

numerice (15,0) but want to display as (15,2)

Post by jflummer »

We have a textbox with a value bound to a program field (in a subfile grid)
The data type is decimal and the length is 15 with 0 decimals. Field Formatting = Number. how can i display as (15,2). this is the JDE database file which does not store with decimal positions but users want to see decimal positions. This display file created a while back now business wants the decimals. thanks.
riback9
New User
Posts: 7
Joined: Tue Sep 01, 2015 10:24 am
First Name: Robert
Last Name: Bucklad
Company Name: Astro-Med
Phone: 401 828-4000 x231
Address 1: 600 East Greenwich Ave
City: West Warwick
State / Province: Rhode Island
Zip / Postal Code: 02893
Country: United States
Contact:

Re: numerice (15,0) but want to display as (15,2)

Post by riback9 »

divide by 100 in a work field 15,2 - load the work field to the display.
Scott Klement
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: numerice (15,0) but want to display as (15,2)

Post by Scott Klement »

I agree with riback9, that'd be the easiest and most fool-proof method.
jflummer
New User
Posts: 9
Joined: Tue May 28, 2019 11:38 am
First Name: jacqueline
Last Name: flummer
Company Name: CSS industries
Address 1: 2 whistler hill lane
City: huntington
State / Province: New York
Zip / Postal Code: 11743
Country: United States
Contact:

Re: numerice (15,0) but want to display as (15,2)

Post by jflummer »

thank you. i'll prob do that. There's about 30 numeric fields like this - hoping not to modify the program. was hoping to do via visual designer. maybe in the properties - custom javascript function ? using sql cast or something? just wasn't sure how to make the custom function take a variable so i could use the same function for all the fields. Trying something like this :
function addposdec(gbapyc) {return (num .tofixed(2) )} -- Tried it but didn't work. since these subfile fields are bound, i didn't want to do any code.
Scott Klement
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: numerice (15,0) but want to display as (15,2)

Post by Scott Klement »

If you wanted to do it in the display, you'd probably want to use a custom formatter:
https://core.profoundlogic.com/docs/dis ... +Formatter

However, I can't say I've tried using it for this particular purpose.
jflummer
New User
Posts: 9
Joined: Tue May 28, 2019 11:38 am
First Name: jacqueline
Last Name: flummer
Company Name: CSS industries
Address 1: 2 whistler hill lane
City: huntington
State / Province: New York
Zip / Postal Code: 11743
Country: United States
Contact:

Re: numerice (15,0) but want to display as (15,2)

Post by jflummer »

thank you. i did review that documentation previously but not exactly what i needed. instead i tried an alternate valid sQL as the function, but no luck. THIS is the code inside the addposdec.js document: function addposdec(gbapyc) {Cast (gbapyc as decimal(15,2) )}. all i put inside the 'custom javascript function' box was the actual funtion name, as the example shows.... "addposdec" - but how is this variable getting to the function? this is the piece i'm not seeing in the documentation. thanks.
Scott Klement
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: numerice (15,0) but want to display as (15,2)

Post by Scott Klement »

The custom Javascript function must be written in Javascript. It doesn't understand SQL syntax.

The only variable that I see is the parameter passed into the function (called 'params' in the documentation link, above. Or 'gbapyc' in your example.) It gets there because it's passed as a parameter...
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests