comparison app/controller/Proben.js @ 448:bd2b26c249e2

Use 'load', not 'reload' to fill the proben store if its empty.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 Dec 2013 11:18:43 +0100
parents 85238577adc9
children e18b170b34bc
comparison
equal deleted inserted replaced
447:12231f31c112 448:bd2b26c249e2
211 }, 211 },
212 createSuccess: function(form, record, response) { 212 createSuccess: function(form, record, response) {
213 // Close Createdialog 213 // Close Createdialog
214 var win = form.up('window'); 214 var win = form.up('window');
215 win.close(); 215 win.close();
216 var resp = Ext.decode(response.responseText);
217 var warn = Array();
218 var err = Array();
219 if (resp.warnings) {
220 warn.push("<strong>Warnungen:</strong><br>");
221 for (var key in resp.warnings) {
222 warn.push(key + ": ");
223 warn.push(Lada.getApplication().bundle.getMsg(resp.warnings[key]) + "<br>");
224 }
225 }
226 if (resp.errors) {
227 err.push("<strong>Fehler:</strong><br>");
228 for (var key in resp.errors) {
229 err.push(key + ": ");
230 err.push(Lada.getApplication().bundle.getMsg(resp.warnings[key]) + "<br>");
231 }
232 }
233 var msg = warn.join("") + err.join("");
234 Ext.MessageBox.alert("Ergebnis", msg);
235 // Reload store
236 var store = this.getProbenStore(); 216 var store = this.getProbenStore();
237 store.reload({ 217 //Load or reload the probenstore.
238 scope: this, 218 if (store.getCount() === 0) {
239 callback: function(records, operation, success) { 219 store.load({
240 console.log('Reloaded store'); 220 scope: this,
241 // Open Editdialog 221 callback: function(records, operation, success) {
242 var json = Ext.decode(response.responseText); 222 console.log('Loaded store');
243 if (json) { 223 // Open Editdialog
244 var probeId = json.data.probeId; 224 var json = Ext.decode(response.responseText);
245 var probe = store.findRecord("probeId", probeId); 225 if (json) {
246 this.editItem(null, probe); 226 var probeId = json.data.probeId;
227 var probe = store.findRecord("probeId", probeId);
228 this.editItem(null, probe);
229 }
247 } 230 }
248 } 231 });
249 }); 232 }
233 else {
234 store.reload({
235 scope: this,
236 callback: function(records, operation, success) {
237 console.log('Reloaded store');
238 // Open Editdialog
239 var json = Ext.decode(response.responseText);
240 if (json) {
241 var probeId = json.data.probeId;
242 var probe = store.findRecord("probeId", probeId);
243 this.editItem(null, probe);
244 }
245 }
246 });
247 }
250 }, 248 },
251 editSuccess: function(form, record, response) { 249 editSuccess: function(form, record, response) {
252 // Reload store 250 // Reload store
253 var store = this.getProbenStore(); 251 var store = this.getProbenStore();
254 store.reload(); 252 store.reload();

http://lada.wald.intevation.org