diff app/view/grid/Probenzusatzwert.js @ 1123:4f68511ce7a4

Restrict range of values to two-digit exponent and format it nicely.
author Tom Gottfried <tom@intevation.de>
date Mon, 23 May 2016 17:50:47 +0200
parents b73f9a976c82
children 5941ee0c7247
line wrap: on
line diff
--- a/app/view/grid/Probenzusatzwert.js	Mon May 23 17:07:50 2016 +0200
+++ b/app/view/grid/Probenzusatzwert.js	Mon May 23 17:50:47 2016 +0200
@@ -94,12 +94,21 @@
             flex: 1,
             editor: {
                 xtype: 'expnumberfield',
+                maxValue: 9.99e+99,
+                minValue: 1e-99
             },
             renderer: function(value) {
                 if (!value || value === '') {
                     return value;
                 }
-                return value.toExponential(2).toString().replace('.', ',');
+                var strValue = value.toExponential(2).toString()
+                    .replace('.', Ext.util.Format.decimalSeparator);
+                var splitted = strValue.split('e');
+                var exponent = parseInt(splitted[1]);
+                return splitted[0] + 'e'
+                    + ((exponent < 0) ? '-' : '+')
+                    + ((Math.abs(exponent) < 10) ? '0' : '')
+                    + Math.abs(exponent).toString();
             }
         }, {
             header: '< NWG',
@@ -119,12 +128,21 @@
             flex: 1,
             editor: {
                 xtype: 'expnumberfield',
+                maxValue: 9.99e+99,
+                minValue: 1e-99
             },
             renderer: function(value) {
                 if (!value || value === '') {
                     return value;
                 }
-                return value.toExponential(2).toString().replace('.', ',');
+                var strValue = value.toExponential(2).toString()
+                    .replace('.', Ext.util.Format.decimalSeparator);
+                var splitted = strValue.split('e');
+                var exponent = parseInt(splitted[1]);
+                return splitted[0] + 'e'
+                    + ((exponent < 0) ? '-' : '+')
+                    + ((Math.abs(exponent) < 10) ? '0' : '')
+                    + Math.abs(exponent).toString();
             }
         }, {
             header: 'Maßeinheit',

http://lada.wald.intevation.org