diff app/view/grid/Status.js @ 824:fab0b7be5aca

add disbled remove button to all grids which relate to proben or messungen. Messprogramme-grids are untouched. BUG: When the last entry is deleted, the button remains active
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 14:23:03 +0200
parents ad24af3fcf89
children 07dfcdf5b41f
line wrap: on
line diff
--- a/app/view/grid/Status.js	Fri May 29 14:03:18 2015 +0200
+++ b/app/view/grid/Status.js	Fri May 29 14:23:03 2015 +0200
@@ -21,6 +21,8 @@
     },
 
     recordId: null,
+    readOnly: true,
+    allowDeselect: true,
 
     initComponent: function() {
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
@@ -116,8 +118,19 @@
                 enforceMaxLength: true
             }
         }];
+        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() {
@@ -147,8 +160,28 @@
             if (this.getPlugin('rowedit')){
                 this.getPlugin('rowedit').enable();
             }
-            this.down('button[action=delete]').enable();
+            //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