[Lada-commits] [PATCH] Restrict range of values to two-digit exponent and format it nicely
Wald Commits
scm-commit at wald.intevation.org
Mon May 23 17:50:52 CEST 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1464018647 -7200
# Node ID 4f68511ce7a41b9e2274e3f0ed46ebaa88e0af64
# Parent 49189f7b4d2f9e6635dd07890a357b8ff4bbf717
Restrict range of values to two-digit exponent and format it nicely.
diff -r 49189f7b4d2f -r 4f68511ce7a4 app/view/grid/Messwert.js
--- a/app/view/grid/Messwert.js Mon May 23 17:07:50 2016 +0200
+++ b/app/view/grid/Messwert.js Mon May 23 17:50:47 2016 +0200
@@ -117,9 +117,21 @@
editor: {
xtype: 'expnumberfield',
allowBlank: false,
+ maxValue: 9.99e+99,
+ minValue: 1e-99
},
renderer: function(value) {
- return value.toExponential(2).toString().replace('.', ',');
+ if (!value || value === '') {
+ return value;
+ }
+ 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: 'Messeinheit',
@@ -163,13 +175,22 @@
dataIndex: 'nwgZuMesswert',
width: 80,
editor: {
- xtype: 'expnumberfield'
+ 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: 'Grenzwertüberschreitung',
diff -r 49189f7b4d2f -r 4f68511ce7a4 app/view/grid/Probenzusatzwert.js
--- 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',
More information about the Lada-commits
mailing list