comparison app/view/grid/Messwert.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
comparison
equal deleted inserted replaced
1122:49189f7b4d2f 1123:4f68511ce7a4
115 dataIndex: 'messwert', 115 dataIndex: 'messwert',
116 width: 80, 116 width: 80,
117 editor: { 117 editor: {
118 xtype: 'expnumberfield', 118 xtype: 'expnumberfield',
119 allowBlank: false, 119 allowBlank: false,
120 }, 120 maxValue: 9.99e+99,
121 renderer: function(value) { 121 minValue: 1e-99
122 return value.toExponential(2).toString().replace('.', ','); 122 },
123 renderer: function(value) {
124 if (!value || value === '') {
125 return value;
126 }
127 var strValue = value.toExponential(2).toString()
128 .replace('.', Ext.util.Format.decimalSeparator);
129 var splitted = strValue.split('e');
130 var exponent = parseInt(splitted[1]);
131 return splitted[0] + 'e'
132 + ((exponent < 0) ? '-' : '+')
133 + ((Math.abs(exponent) < 10) ? '0' : '')
134 + Math.abs(exponent).toString();
123 } 135 }
124 }, { 136 }, {
125 header: 'Messeinheit', 137 header: 'Messeinheit',
126 dataIndex: 'mehId', 138 dataIndex: 'mehId',
127 width: 90, 139 width: 90,
161 }, { 173 }, {
162 header: 'Nachweisgrenze', 174 header: 'Nachweisgrenze',
163 dataIndex: 'nwgZuMesswert', 175 dataIndex: 'nwgZuMesswert',
164 width: 80, 176 width: 80,
165 editor: { 177 editor: {
166 xtype: 'expnumberfield' 178 xtype: 'expnumberfield',
179 maxValue: 9.99e+99,
180 minValue: 1e-99
167 }, 181 },
168 renderer: function(value) { 182 renderer: function(value) {
169 if (!value || value === '') { 183 if (!value || value === '') {
170 return value; 184 return value;
171 } 185 }
172 return value.toExponential(2).toString().replace('.', ','); 186 var strValue = value.toExponential(2).toString()
187 .replace('.', Ext.util.Format.decimalSeparator);
188 var splitted = strValue.split('e');
189 var exponent = parseInt(splitted[1]);
190 return splitted[0] + 'e'
191 + ((exponent < 0) ? '-' : '+')
192 + ((Math.abs(exponent) < 10) ? '0' : '')
193 + Math.abs(exponent).toString();
173 } 194 }
174 }, { 195 }, {
175 header: 'Grenzwertüberschreitung', 196 header: 'Grenzwertüberschreitung',
176 dataIndex: 'grenzwertueberschreitung', 197 dataIndex: 'grenzwertueberschreitung',
177 flex: 1, 198 flex: 1,

http://lada.wald.intevation.org