diff app/view/widget/DynamicGrid.js @ 975:fb99332bb48e stammdatengrids

Severe changes concerning the Resultgrids. - Intrduced "Stammdaten" which can be selected in the Mode Field on the left side, - Added Stores and Models for the Stammdaten - Removed the FilterResultgrid and replaced it with a model which uses inheritance. Dynamic Grid Columns can now be derived from app/view/widget/DynamicGrid.js For Proben and Messprogramme this is already done. - There might be some REGRESSION concerning the buttons in the ProbeList and MessprogrammeList grid, as those are not disabled properly. This needs to be fixed in future commits.
author Dustin Demuth <dustin@intevation.de>
date Wed, 02 Dec 2015 17:39:04 +0100
parents
children 3c770fc7cf19
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/DynamicGrid.js	Wed Dec 02 17:39:04 2015 +0100
@@ -0,0 +1,108 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Grid to list the result of the Filter
+ */
+Ext.define('Lada.view.widget.DynamicGrid', {
+    extend: 'Ext.grid.Panel',
+
+    store: null,
+
+    multiSelect: true,
+
+    viewConfig: {
+        deferEmptyText: false
+    },
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.callParent(arguments);
+    },
+
+    /**
+     * This sets the Store of the DynamicGrid
+     */
+    setStore: function(store){
+        var i18n = Lada.getApplication().bundle;
+
+        this.removeDocked(Ext.getCmp('ptbar'), true);
+        this.reconfigure(store);
+        this.addDocked([{
+            xtype: 'pagingtoolbar',
+            id: 'ptbar',
+            dock: 'bottom',
+            store: store,
+            displayInfo: true
+        }]);
+
+    },
+
+    /**
+     * Setup columns of the Grid dynamically based on a list of given cols.
+     * The function is called from the {@link Lada.controller.Filter#search
+     * search event}
+     * The Images for the Read-Write Icon are defined in CSS
+     */
+    setupColumns: function(cols) {
+        var caf = this.generateColumnsAndFields(cols);
+        var columns = caf[0];
+        var fields = caf[1];
+        this.store.model.setFields(fields);
+        this.reconfigure(this.store, columns);
+    },
+
+    /**
+     * generateColumnsAndFields
+     * generates an array of columns which are used for the dynamic grid
+     * @return an array of two arrays: [0] is an array of colums [1] an array
+     *   of fields
+     **/
+     generateColumnsAndFields: function(cols) {
+        var resultColumns = [];
+        var fields = [];
+
+        fields.push(new Ext.data.Field({
+            name: 'owner'
+        }));
+        fields.push(new Ext.data.Field({
+            name: 'readonly'
+        }));
+
+        resultColumns.push({
+            xtype: 'actioncolumn',
+            text: 'RW',
+            dataIndex: 'readonly',
+            sortable: false,
+            tooltip: 'Probe öffnen',
+            width: 30,
+            getClass: function (val, meta, rec) {
+                return rec.get('readonly') === false ? "edit" : "noedit";
+            },
+            handler: function(grid, rowIndex, colIndex) {
+                var rec = grid.getStore().getAt(rowIndex);
+                grid.fireEvent('itemdblclick', grid, rec);
+             }
+        });
+
+        for (var i = cols.length - 1; i >= 0; i--) {
+            if (cols[i] === 'id') {
+                continue;
+            }
+            resultColumns.push(cols[i]);
+            fields.push(new Ext.data.Field({
+                name: cols[i].dataIndex
+            }));
+        }
+        var caf = new Array();
+        caf[0] = resultColumns;
+        caf[1] = fields;
+        return caf;
+     }
+});
+

http://lada.wald.intevation.org