changeset 637:8acb3123b46c

Remove a new record on cancel in grids with rowediting plugin.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 Mar 2015 10:21:29 +0100
parents f4f76fc04e28
children d21048cbdbb3
files app/controller/grid/MKommentar.js app/controller/grid/Messwert.js app/controller/grid/PKommentar.js app/controller/grid/Probenzusatzwert.js app/controller/grid/Status.js
diffstat 5 files changed, 45 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/grid/MKommentar.js	Mon Mar 16 17:32:15 2015 +0100
+++ b/app/controller/grid/MKommentar.js	Tue Mar 17 10:21:29 2015 +0100
@@ -12,7 +12,8 @@
     init: function() {
         this.control({
             'mkommentargrid': {
-                edit: this.edit
+                edit: this.edit,
+                canceledit: this.cancelEdit
             },
             'mkommentargrid button[action=add]': {
                 click: this.add
@@ -35,6 +36,13 @@
         });
     },
 
+    cancelEdit: function(editor, context) {
+        if (!context.record.get('id') ||
+            context.record.get('id') === '') {
+            editor.getCmp().store.remove(context.record);
+        }
+    },
+
     add: function(button) {
         var record = Ext.create('Lada.model.MKommentar');
         record.set('messungsId', button.up('mkommentargrid').recordId);
--- a/app/controller/grid/Messwert.js	Mon Mar 16 17:32:15 2015 +0100
+++ b/app/controller/grid/Messwert.js	Tue Mar 17 10:21:29 2015 +0100
@@ -12,7 +12,8 @@
     init: function() {
         this.control({
             'messwertgrid': {
-                edit: this.gridSave
+                edit: this.gridSave,
+                canceledit: this.cancelEdit
             },
             'messwertgrid button[action=add]': {
                 click: this.add
@@ -35,6 +36,13 @@
         });
     },
 
+    cancelEdit: function(editor, context) {
+        if (!context.record.get('id') ||
+            context.record.get('id') === '') {
+            editor.getCmp().store.remove(context.record);
+        }
+    },
+
     add: function(button) {
         var record = Ext.create('Lada.model.Messwert', {
             messungsId: button.up('messwertgrid').recordId
--- a/app/controller/grid/PKommentar.js	Mon Mar 16 17:32:15 2015 +0100
+++ b/app/controller/grid/PKommentar.js	Tue Mar 17 10:21:29 2015 +0100
@@ -12,7 +12,8 @@
     init: function() {
         this.control({
             'pkommentargrid': {
-                edit: this.edit
+                edit: this.edit,
+                canceledit: this.cancelEdit
             },
             'pkommentargrid button[action=add]': {
                 click: this.add
@@ -35,6 +36,13 @@
         });
     },
 
+    cancelEdit: function(editor, context) {
+        if (!context.record.get('id') ||
+            context.record.get('id') === '') {
+            editor.getCmp().store.remove(context.record);
+        }
+    },
+
     add: function(button) {
         var record = Ext.create('Lada.model.PKommentar');
         record.set('probeId', button.up('pkommentargrid').recordId);
--- a/app/controller/grid/Probenzusatzwert.js	Mon Mar 16 17:32:15 2015 +0100
+++ b/app/controller/grid/Probenzusatzwert.js	Tue Mar 17 10:21:29 2015 +0100
@@ -12,7 +12,8 @@
     init: function() {
         this.control({
             'probenzusatzwertgrid': {
-                edit: this.gridSave
+                edit: this.gridSave,
+                canceledit: this.cancelEdit
             },
             'probenzusatzwertgrid button[action=add]': {
                 click: this.add
@@ -35,6 +36,13 @@
         });
     },
 
+    cancelEdit: function(editor, context) {
+        if (!context.record.get('id') ||
+            context.record.get('id') === '') {
+            editor.getCmp().store.remove(context.record);
+        }
+    },
+
     add: function(button) {
         var record = Ext.create('Lada.model.Zusatzwert', {
             probeId: button.up('probenzusatzwertgrid').recordId
--- a/app/controller/grid/Status.js	Mon Mar 16 17:32:15 2015 +0100
+++ b/app/controller/grid/Status.js	Tue Mar 17 10:21:29 2015 +0100
@@ -12,7 +12,8 @@
     init: function() {
         this.control({
             'statusgrid': {
-                edit: this.gridSave
+                edit: this.gridSave,
+                canceledit: this.cancelEdit
             },
             'statusgrid button[action=add]': {
                 click: this.add
@@ -35,6 +36,13 @@
         });
     },
 
+    cancelEdit: function(editor, context) {
+        if (!context.record.get('id') ||
+            context.record.get('id') === '') {
+            editor.getCmp().store.remove(context.record);
+        }
+    },
+
     add: function(button) {
         var record = Ext.create('Lada.model.Status', {
             messungsId: button.up('statusgrid').recordId

http://lada.wald.intevation.org