diff app/controller/Proben.js @ 256:d8993f5b96e8

Added a possible fix for issue57. After the create dialog is closed the edit window is opened.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 25 Jul 2013 09:26:43 +0200
parents 82118c01bc52
children 0d6552bb28ea
line wrap: on
line diff
--- a/app/controller/Proben.js	Wed Jul 24 19:14:02 2013 +0200
+++ b/app/controller/Proben.js	Thu Jul 25 09:26:43 2013 +0200
@@ -75,18 +75,24 @@
         console.log("Loaded Probe with ID " + record.getId()); //outputs ID
     },
     createSuccess: function(form, record, response) {
-        // Reload store
-        //var store = this.getProbenStore();
-        //store.reload();
+        // Close Createdialog
         var win = form.up('window');
         win.close();
-        // Open Editdialog
-        var json = Ext.decode(response.responseText);
-        if (json) {
-            var probeId = json.data.probeId;
-            record.set('probeId', probeId);
-        }
-        this.editProbe(null, record);
+        // Reload store
+        var store = this.getProbenStore();
+        store.reload({
+            scope: this,
+            callback: function(records, operation, success) {
+                console.log('Reloaded store');
+                // Open Editdialog
+                var json = Ext.decode(response.responseText);
+                if (json) {
+                    var probeId = json.data.probeId;
+                    var probe = store.findRecord("probeId", probeId);
+                    this.editProbe(null, probe);
+                }
+            }
+        });
     },
     createFailure: function(form, record, response) {
         Ext.MessageBox.show({

http://lada.wald.intevation.org