Roo/form/NumberField.js
authorAlan <alan@roojs.com>
Tue, 26 Mar 2024 08:49:00 +0000 (16:49 +0800)
committerAlan <alan@roojs.com>
Tue, 26 Mar 2024 08:49:00 +0000 (16:49 +0800)
Roo/form/NumberField.js

index cb4ba06..ce1f025 100644 (file)
@@ -123,7 +123,7 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField,  {
 
     // private
     parseValue : function(value){
-        value = parseFloat(String(value).replace(this.decimalSeparator, "."));
+        value = parseFloat(String(value).replace(this.decimalSeparator, ".").replace(this.thousandSeparator, ''));
         return isNaN(value) ? '' : value;
     },
 
@@ -138,6 +138,11 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField,  {
 
     setValue : function(v){
         v = this.fixPrecision(v);
+        if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
+            //noop 
+        } else {
+            v = Roo.util.Format.number(v, this.decimalPrecision, this.thousandSeparator);
+        }
         Roo.form.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
     },