comparison app/view/form/ExpNumberField.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
children
comparison
equal deleted inserted replaced
1118:ea5774447e49 1119:b73f9a976c82
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 /**
10 * Number field for display and editing of exponential numbers
11 */
12 Ext.define('Lada.view.form.ExpNumberField', {
13 extend: 'Ext.form.field.Number',
14 alias: 'widget.expnumberfield',
15
16 baseChars: '0123456789eE',
17
18 hideTrigger: true,
19 keyNavEnabled: false,
20 mouseWheelEnabled: false,
21
22 valueToRaw: function(value) {
23 if (!value || value === '') {
24 return value;
25 }
26
27 // XXX: this will be applied to any input before being sent to
28 // the server! Thus, toExponential(2) would lead to incorrectly
29 // rounded numbers at this point.
30 value = parseFloat(value).toExponential()
31 .toString().replace('.', this.decimalSeparator);
32
33 return value;
34 },
35
36 rawToValue: function(value) {
37 if (!value || value === '') {
38 return value;
39 }
40
41 value = parseFloat(
42 value.toString().replace(this.decimalSeparator, '.'));
43
44 return value;
45 }
46 });

http://lada.wald.intevation.org