diff app/controller/grid/PKommentar.js @ 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 cf328526b5bb
children f0bc5387abcc
line wrap: on
line diff
--- 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);

http://lada.wald.intevation.org