PDA

View Full Version : [CLOSED] Number field display DP



CanopiusApplications
Oct 16, 2014, 1:25 PM
Guys

I have a number field which is setup like below




<ext:NumberField ID="_LossDeminimis" runat="server" AllowDecimals="true" Step="0.000000001" DecimalPrecision="9" MinValue="0.000000001" MaxValue="0.999999999" FieldLabel="Loss Deminimis" PaddingSpec="0 0 0 20" flex="1"></ext:NumberField>



The issue is that in the front end it displays as "1e-9" which is not very user friendly, so I do I force it to display as "0.000000001"

Ta,
D

CanopiusApplications
Oct 16, 2014, 4:32 PM
Not to worry this can be closed as my user is quite happy working with the scientific notation.

Ta,
D

Daniil
Oct 16, 2014, 4:54 PM
Hi @CanopiusApplications,

There is a property to turn it off if needed.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Number-cfg-allowExponential

CanopiusApplications
Oct 16, 2014, 5:44 PM
Hi Danil

Yeah I saw that but when I tried it I was still getting the the scientific notation.
I have just given it another go but with no joy




<ext:NumberField ID="_EPS" AllowBlank="false" AllowExponential="false" runat="server" AllowDecimals="true" Step="0.000000001" DecimalPrecision="9" MinValue="0.000000001" MaxValue="0.999999999" FieldLabel="EPS" PaddingSpec="0 0 0 20" flex="1"></ext:NumberField>

Daniil
Oct 16, 2014, 6:27 PM
It appears to be a JavaScript "feature". If you try to run

alert(0.000000001);
you will see "1e-9".

CanopiusApplications
Oct 17, 2014, 8:43 AM
Yeah I figured it to be something along those lines. .net formats it to the scientific notification by default as well when converting to string.
no biggy though as the user is happy. a work around to use a text box and then convert tostring specifying the format

num.tostring(0,000000000)

this works but you lose the spinner capabilities of the number field and it requires additional validation.

Either way this can be closed.


Thanks again d, as always very helpful.

D