diff app/view/grid/Messwert.js @ 1119:b73f9a976c82

Exponential notation without tampering numbers. Rounding is done by the server. Thus, the client should not fix the number of digits, except only for rendering.
author Tom Gottfried <tom@intevation.de>
date Mon, 23 May 2016 16:00:50 +0200
parents e76551a6da27
children 4f68511ce7a4
line wrap: on
line diff
--- a/app/view/grid/Messwert.js	Mon May 23 11:39:19 2016 +0200
+++ b/app/view/grid/Messwert.js	Mon May 23 16:00:50 2016 +0200
@@ -14,6 +14,7 @@
     alias: 'widget.messwertgrid',
 
     requires: [
+        'Lada.view.form.ExpNumberField',
         'Lada.view.widget.Messgroesse',
         'Lada.view.widget.Messeinheit'
     ],
@@ -114,10 +115,11 @@
             dataIndex: 'messwert',
             width: 80,
             editor: {
-                xtype: 'textfield',
+                xtype: 'expnumberfield',
                 allowBlank: false,
-                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
-                regexText: 'Keine Zahl'
+            },
+            renderer: function(value) {
+                return value.toExponential(2).toString().replace('.', ',');
             }
         }, {
             header: 'Messeinheit',
@@ -161,10 +163,13 @@
             dataIndex: 'nwgZuMesswert',
             width: 80,
             editor: {
-                xtype: 'textfield',
-                allowBlank: true,
-                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
-                regexText: 'Keine Zahl'
+                xtype: 'expnumberfield'
+            },
+            renderer: function(value) {
+                if (!value || value === '') {
+                    return value;
+                }
+                return value.toExponential(2).toString().replace('.', ',');
             }
         }, {
             header: 'Grenzwertüberschreitung',

http://lada.wald.intevation.org