Mercurial > lada > lada-client
diff app/controller/grid/Messmethode.js @ 767:5ee59111b188
Add/Remove is now reliable
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 12 May 2015 14:53:54 +0200 |
parents | 31eaed998531 |
children | 380edfecac67 |
line wrap: on
line diff
--- a/app/controller/grid/Messmethode.js Tue May 12 14:24:41 2015 +0200 +++ b/app/controller/grid/Messmethode.js Tue May 12 14:53:54 2015 +0200 @@ -85,7 +85,32 @@ */ gridSaveNuklid: function(editor, context) { console.log(context); - this.syncArray(context.store); + var modified = false; + var id = context.newValues.id; + var mg = this.record.get('messgroessen'); + + //Test if this Nuklid already exists. + if (Array.isArray(id)){ + for (i in id) { + //Only insert if value does not exist + if (! Ext.Array.contains(mg, id[i])) { + modified = true; + } + } + } + else { + if (! Ext.Array.contains(mg, id)) { + mg.push(id); + modified = true; + } + } + + if (modified) { + this.syncArray(context.store); + } + else { + editor.getCmp().store.remove(context.record); + } }, /**