diff app/controller/form/Ortszuordnung.js @ 1022:6d33a84979e4 stammdatengrids

More work on the Ortszuordnung grid. Saving does not work yet
author Dustin Demuth <dustin@intevation.de>
date Mon, 08 Feb 2016 10:33:25 +0100
parents 1df6b6210b42
children 2e7adc19b4fe
line wrap: on
line diff
--- a/app/controller/form/Ortszuordnung.js	Thu Feb 04 16:31:46 2016 +0100
+++ b/app/controller/form/Ortszuordnung.js	Mon Feb 08 10:33:25 2016 +0100
@@ -39,18 +39,18 @@
       */
      save: function(button) {
 
+        var formPanel = button.up('ortszuordnungform');
+
         //try to disable ortPickerButton:
         try {
-           var ob = this.up('form').down('ortszuordnungform button[action=setOrt]');
-           if (ob.pressed) {
-                ob.toggle(false);
-            }
+           formPanel.down('button[action=setOrt]').toggle(false);
         }
         catch (e) {
         }
 
-        var formPanel = button.up('ortszuordnungform');
         var data = formPanel.getForm().getFieldValues(true);
+        debugger;
+        console.log(data);
         var i18n = Lada.getApplication().bundle;
         for (var key in data) {
             formPanel.getForm().getRecord().set(key, data[key]);
@@ -70,6 +70,14 @@
                     formPanel.setMessages(json.errors, json.warnings);
                     formPanel.up('window').grid.store.reload();
                 }
+                //try to refresh the Grid of the Probe
+                try {
+                    formPanel.up('window').parentWindow
+                        .down('ortszuordnunggrid').store.reload();
+                }
+                catch (e) {
+
+                }
             },
             failure: function(record, response) {
                 button.setDisabled(true);
@@ -104,7 +112,16 @@
      */
     discard: function(button) {
         var formPanel = button.up('form');
-        formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+        var record = formPanel.getForm().getRecord();
+        formPanel.getForm().loadRecord(record);
+        try {
+            formPanel.refreshOrt(record.get('ortId'));
+            formPanel.down('button[action=setOrt]').toggle(false);
+        }
+        catch (e) {
+        }
+        //set undirty.
+        formPanel.fireEvent('dirtychange', formPanel.getForm(), false);
     },
 
     /**

http://lada.wald.intevation.org