From: Alan Date: Tue, 26 Mar 2024 09:12:49 +0000 (+0800) Subject: trying to get thousand seperator to work X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=6892d65bd29535459fd48df743b5c2dd1494585b trying to get thousand seperator to work --- diff --git a/Roo/form/NumberField.js b/Roo/form/NumberField.js index 9d7cb1ddc4..5fa9597398 100644 --- a/Roo/form/NumberField.js +++ b/Roo/form/NumberField.js @@ -76,6 +76,7 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { if(this.allowDecimals){ allowed += this.decimalSeparator; } + allowed += this.thousandSeparator; if(this.allowNegative){ allowed += "-"; } diff --git a/roojs-all.js b/roojs-all.js index 8b3080839e..77f58cf059 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1822,12 +1822,12 @@ Roo.form.TextArea=function(A){Roo.form.TextArea.superclass.constructor.call(this }v+=" \n ";}ts.innerHTML=v;var h=Math.min(this.growMax,Math.max(ts.offsetHeight,this.growMin));if(h!=this.lastHeight){this.lastHeight=h;this.el.setHeight(h);this.fireEvent("autosize",this,h);}}}); // Roo/form/NumberField.js Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",thousandSeparator:"",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); -var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return;}var c=e.getCharCode(); -if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A);if(isNaN(B)){this.markInvalid(String.format(this.nanText,A)); -return false;}if(Bthis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false;}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this))); -},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;} -return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator);}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator)); -},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); +var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}A+=this.thousandSeparator;if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return; +}var c=e.getCharCode();if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A); +if(isNaN(B)){this.markInvalid(String.format(this.nanText,A));return false;}if(Bthis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false; +}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this)));},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A; +},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator); +}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator));},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); // Roo/form/DateField.js Roo.form.DateField=function(A){Roo.form.DateField.superclass.constructor.call(this,A);this.addEvents({'select':true});if(typeof this.minValue=="string"){this.minValue=this.parseDate(this.minValue);}if(typeof this.maxValue=="string"){this.maxValue=this.parseDate(this.maxValue); }this.ddMatch=null;if(this.disabledDates){var dd=this.disabledDates;var re="(?:";for(var i=0;ithis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false;}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this))); -},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;} -return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator);}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator)); -},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); +var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}A+=this.thousandSeparator;if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return; +}var c=e.getCharCode();if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A); +if(isNaN(B)){this.markInvalid(String.format(this.nanText,A));return false;}if(Bthis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false; +}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this)));},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A; +},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator); +}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator));},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); // Roo/form/DateField.js Roo.form.DateField=function(A){Roo.form.DateField.superclass.constructor.call(this,A);this.addEvents({'select':true});if(typeof this.minValue=="string"){this.minValue=this.parseDate(this.minValue);}if(typeof this.maxValue=="string"){this.maxValue=this.parseDate(this.maxValue); }this.ddMatch=null;if(this.disabledDates){var dd=this.disabledDates;var re="(?:";for(var i=0;i