PDA

View Full Version : [1.1.1] NumberField.getValue() returns String if decimalPrecision used



sjivan
19 Oct 2007, 5:27 AM
Ext 1.1.1
OS : Windows
Browser : IE 6.0

There was a change in Ext 1.1.1 where NumberField.getValue now calls toFixed(..) if allowDecimals and decimalPrecision. I think this change was made in 1.1.1 because of this : http://extjs.com/forum/showthread.php?t=10418

In Ext 1.1.1



fixPrecision : function(value){
var nan = isNaN(value);
if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
return nan ? '' : value;
}
return parseFloat(value).toFixed(this.decimalPrecision);
}


The problem is that toFixed(..) converts the number into a String data type (tested in IE). I've locally added a parseFloat(..) call after the toFixed() to convert the String back to a number type. Does this change make sense?

Sanjiv

sjivan
28 Oct 2007, 4:11 PM
I see that this fix has been made to Ext 2.0. Any idea when the next 1.1.x release will be out with these fixes?

Thanks,
Sanjiv

mystix
1 Nov 2007, 11:32 PM
hi sanjiv,

the changes are already in 1.1.1 SVN.
no details on a release date though. :(

here's the actual snippet from SVN:


// private
fixPrecision : function(value){
var nan = isNaN(value);
if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
return nan ? '' : value;
}
return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
}

so yes, your suggested fix above is correct :)

sjivan
2 Nov 2007, 7:01 PM
Cool, thanks.

mystix
5 Nov 2007, 11:15 PM
hmm.. there seems to be some serious regression problems with the NumberField.. i'll post a report in 2.0 bugs and check back in here with the results.