comparison app/view/grid/Messung.js @ 1032:fa04558f35cd

Load messung grid columns as record fields to get rid of 'Ext.fly'
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 18 Feb 2016 11:16:55 +0100
parents 989736bf4ffb
children e4b6b6c5fb89
comparison
equal deleted inserted replaced
1031:488fed1d2b98 1032:fa04558f35cd
79 maxValue: Ext.Date.format(new Date(), 'd.m.Y H:i') 79 maxValue: Ext.Date.format(new Date(), 'd.m.Y H:i')
80 } 80 }
81 }, { 81 }, {
82 header: 'Status', 82 header: 'Status',
83 flex: 1, 83 flex: 1,
84 dataIndex: 'id', 84 dataIndex: 'statusWert',
85 renderer: function(value) { 85 renderer: function(value, meta, record, rNdx, cNdx) {
86 var statusId = this.store.getById(value).get('status'); 86 var statusId = record.get('status');
87 var divId = 'messung-status-item' + value; 87 var mId = record.get('id');
88 //also fwd the record to the asynchronous loading of statuswerte 88 //also fwd the record to the asynchronous loading of statuswerte
89 // in order to add the statuswert to the record, 89 // in order to add the statuswert to the record,
90 // after the grid was rendered... 90 // after the grid was rendered...
91 this.updateStatus(value, divId, statusId, this.store.getById(value)); 91 if (value === '') {
92 return '<div id="' + divId + '">Lade...</div>'; 92 this.updateStatus(mId, statusId, record);
93 return 'Lade...';
94 }
95 var sta = Ext.data.StoreManager.getByKey('statuswerte');
96 return sta.getById(value).get('wert');
93 } 97 }
94 }, { 98 }, {
95 header: 'OK-Flag', 99 header: 'OK-Flag',
96 dataIndex: 'fertig', 100 dataIndex: 'fertig',
97 flex: 1, 101 flex: 1,
108 }, { 112 }, {
109 header: 'Anzahl Nuklide', 113 header: 'Anzahl Nuklide',
110 // Gibt die Anzahl der Messwerte wieder, 114 // Gibt die Anzahl der Messwerte wieder,
111 // NICHT die Anzahl der verschiedenen Nukleide 115 // NICHT die Anzahl der verschiedenen Nukleide
112 // Eventuell ist die Bezeichnug daher irreführend 116 // Eventuell ist die Bezeichnug daher irreführend
113 dataIndex: 'id', 117 dataIndex: 'messwerteCount',
114 flex: 1, 118 flex: 1,
115 renderer: function(value) { 119 renderer: function(value, meta, record) {
116 var id = 'messung-nuklid-item' + value; 120 if (value === '') {
117 this.updateNuklide(value, id); 121 var mId = record.get('id');
118 return '<div id="' + id + '">Lade...</div>'; 122 this.updateNuklide(mId, record);
123 return 'Lade...';
124 }
125 return value;
119 } 126 }
120 }, { 127 }, {
121 header: 'Anzahl Kommentare', 128 header: 'Anzahl Kommentare',
122 flex: 1, 129 flex: 1,
123 dataIndex: 'id', 130 dataIndex: 'kommentarCount',
124 renderer: function(value) { 131 renderer: function(value, meta, record) {
125 var id = 'messung-kommentar-item' + value; 132 if (value === '') {
126 this.updateKommentare(value, id); 133 var mId = record.get('id');
127 return '<div id="' + id + '">Lade...</div>'; 134 this.updateKommentare(mId, record);
135 return 'Lade...';
136 }
137 return value;
128 } 138 }
129 }]; 139 }];
130 this.listeners = { 140 this.listeners = {
131 select: { 141 select: {
132 fn: this.activateRemoveButton, 142 fn: this.activateRemoveButton,
158 168
159 /** 169 /**
160 * Load the statusstore, 170 * Load the statusstore,
161 * afterwards: retrieve the statusid 171 * afterwards: retrieve the statusid
162 */ 172 */
163 updateStatus: function(value, divId, statusId, record) { 173 updateStatus: function(value, statusId, record) {
164 var statusStore = Ext.create('Lada.store.Status'); 174 var statusStore = Ext.create('Lada.store.Status');
165 statusStore.on('load', 175 statusStore.on('load',
166 this.updateStatusColumn, 176 this.updateStatusColumn,
167 this, 177 this,
168 {divId: divId, statusId: statusId, record: record}); 178 {statusId: statusId, record: record});
169 statusStore.load({ 179 statusStore.load({
170 params: { 180 params: {
171 messungsId: value 181 messungsId: value
172 } 182 }
173 }); 183 });
174 }, 184 },
175 185
176 updateNuklide: function(value, divId) { 186 updateNuklide: function(id, record) {
177 var messwerte = Ext.create('Lada.store.Messwerte'); 187 var messwerte = Ext.create('Lada.store.Messwerte');
178 messwerte.on('load', 188 messwerte.on('load',
179 this.updateColumn, 189 this.updateColumn,
180 this, 190 this,
181 {divId: divId}); 191 {record: record, type: 'messwerteCount'});
182 messwerte.load({ 192 messwerte.load({
183 params: { 193 params: {
184 messungsId: value 194 messungsId: id
185 } 195 }
186 }); 196 });
187 }, 197 },
188 198
189 updateKommentare: function(value, divId) { 199 updateKommentare: function(id, record) {
190 var kommentare = Ext.create('Lada.store.MKommentare'); 200 var kommentare = Ext.create('Lada.store.MKommentare');
191 kommentare.on('load', 201 kommentare.on('load',
192 this.updateColumn, 202 this.updateColumn,
193 this, 203 this,
194 {divId: divId}); 204 {record: record, type: 'kommentarCount'});
195 kommentare.load({ 205 kommentare.load({
196 params: { 206 params: {
197 messungsId: value 207 messungsId: id
198 } 208 }
199 }); 209 });
200 }, 210 },
201 211
202 updateColumn: function(store, record, success, opts) { 212 updateColumn: function(store, record, success, opts) {
210 } 220 }
211 } 221 }
212 else { 222 else {
213 value = 'k.A.'; 223 value = 'k.A.';
214 } 224 }
215 Ext.fly(opts.divId).update(value); 225 opts.record.beginEdit();
226 opts.record.set(opts.type, value);
227 opts.record.endEdit();
216 }, 228 },
217 229
218 /** 230 /**
219 * Retrieve Statuswert and update the column 231 * Retrieve Statuswert and update the column
220 */ 232 */
228 if (rec) { 240 if (rec) {
229 value = rec.get('statusWert'); 241 value = rec.get('statusWert');
230 //add the determined statuswert to the record. 242 //add the determined statuswert to the record.
231 // this is necessary to let the controller determine 243 // this is necessary to let the controller determine
232 // which actions are allowed. 244 // which actions are allowed.
233 opts.record.data.statusWert = value; 245 opts.record.beginEdit();
234 } 246 opts.record.set('statusWert', value);
235 } 247 opts.record.endEdit();
236 if (Ext.fly(opts.divId)) {
237 //Try to get the statuswerte store,
238 // If it does not exist, create a new one.
239 var sta = Ext.data.StoreManager.getByKey('statuswerte');
240 var val = 'error';
241 if (!sta) {
242 // Set the Data asynchronously
243 sta = Ext.create('Lada.store.StatusWerte');
244 sta.load({
245 scope: this,
246 callback: function(records, operation, success) {
247 if (success) {
248 var item = sta.getById(value);
249 if (item) {
250 val = item.get('wert');
251 }
252 }
253 Ext.fly(opts.divId).update(val);
254 }
255 });
256 }
257 else {
258 // set the data
259 var item = sta.getById(value);
260 if (item) {
261 val = item.get('wert');
262 }
263 Ext.fly(opts.divId).update(val);
264 } 248 }
265 } 249 }
266 }, 250 },
267 251
268 setReadOnly: function(b) { 252 setReadOnly: function(b) {

http://lada.wald.intevation.org