user2940383
user2940383

Reputation: 543

Decimal precision in numberfield - extjs . Can we remove the precision?

In ext js numberfield , there is a config decimalPrecision. By default it will take 2digit precision. I dont want the precision to apply to the field. It should be same as the value that i entered. How to do this ?

Upvotes: 0

Views: 2844

Answers (1)

gus27
gus27

Reputation: 2656

I'd suggest using a textfield with maskRe config option. In that case you have full control over the decimal precision. The downside is that you loose the spin buttons.

{
    xtype: 'textfield',
    name: 'number',
    fieldLabel: 'Number',
    maskRe: new RegExp("[0-9.]+")
}

https://fiddle.sencha.com/#fiddle/ihn

Another option is to dynamically set the precision depending on the number of decimals after the '.'. I created a fiddle: In the "test number" field enter any number with decimal precision, press "Fill number field" and the numberfield below will be filled with the value and the entered precision. https://fiddle.sencha.com/#fiddle/ihp

Upvotes: 1

Related Questions