diff app/view/grid/Ort.js @ 823:5ed0e6273888

Only enable delete button in grids when an entry was selected
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 14:03:18 +0200
parents 69cb367c0a63
children fab0b7be5aca
line wrap: on
line diff
--- a/app/view/grid/Ort.js	Fri May 29 14:02:21 2015 +0200
+++ b/app/view/grid/Ort.js	Fri May 29 14:03:18 2015 +0200
@@ -27,6 +27,8 @@
 
     warnings: null,
     errors: null,
+    readOnly: true,
+    allowDeselect: true,
 
     initComponent: function() {
         this.dockedItems = [{
@@ -92,8 +94,19 @@
                 return record.get('bezeichnung');
             }
         }];
+        this.listeners = {
+           select: {
+               fn: this.activateRemoveButton,
+               scope: this
+            },
+            deselect: {
+                fn: this.deactivateRemoveButton,
+                scope: this
+            }
+        };
         this.initData();
         this.callParent(arguments);
+        this.setReadOnly(true); //Grid is always initialised as RO
     },
 
     initData: function() {
@@ -134,5 +147,25 @@
             this.down('button[action=delete]').enable();
             this.down('button[action=add]').enable();
         }
+    },
+    /**
+     * Activate the Remove Button
+     */
+    activateRemoveButton: function(selection, record) {
+        var grid = this;
+        //only enable the remove buttone, when the grid is editable.
+        if (! grid.readOnly) {
+            grid.down('button[action=delete]').enable();
+        }
+    },
+    /**
+     * Activate the Remove Button
+     */
+    deactivateRemoveButton: function(selection, record) {
+        var grid = this;
+        //only enable the remove buttone, when the grid is editable.
+        if (! grid.readOnly) {
+            grid.down('button[action=delete]').disable();
+        }
     }
 });

http://lada.wald.intevation.org