[Lada-commits] [PATCH] Remove a new record on cancel in grids with rowediting plugin

Wald Commits scm-commit at wald.intevation.org
Tue Mar 17 10:20:45 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1426584089 -3600
# Node ID 8acb3123b46cae862e0c09b4d78146ad35d8da02
# Parent  f4f76fc04e2864cc5cf8e732e776011058013a9d
Remove a new record on cancel in grids with rowediting plugin.

diff -r f4f76fc04e28 -r 8acb3123b46c app/controller/grid/MKommentar.js
--- 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);
diff -r f4f76fc04e28 -r 8acb3123b46c app/controller/grid/Messwert.js
--- 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
diff -r f4f76fc04e28 -r 8acb3123b46c app/controller/grid/PKommentar.js
--- 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);
diff -r f4f76fc04e28 -r 8acb3123b46c app/controller/grid/Probenzusatzwert.js
--- 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
diff -r f4f76fc04e28 -r 8acb3123b46c app/controller/grid/Status.js
--- 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


More information about the Lada-commits mailing list