comparison 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
comparison
equal deleted inserted replaced
974:ea477f62a667 975:fb99332bb48e
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 /**
10 * Grid to list the result of the Filter
11 */
12 Ext.define('Lada.view.widget.DynamicGrid', {
13 extend: 'Ext.grid.Panel',
14
15 store: null,
16
17 multiSelect: true,
18
19 viewConfig: {
20 deferEmptyText: false
21 },
22
23 initComponent: function() {
24 var i18n = Lada.getApplication().bundle;
25 this.callParent(arguments);
26 },
27
28 /**
29 * This sets the Store of the DynamicGrid
30 */
31 setStore: function(store){
32 var i18n = Lada.getApplication().bundle;
33
34 this.removeDocked(Ext.getCmp('ptbar'), true);
35 this.reconfigure(store);
36 this.addDocked([{
37 xtype: 'pagingtoolbar',
38 id: 'ptbar',
39 dock: 'bottom',
40 store: store,
41 displayInfo: true
42 }]);
43
44 },
45
46 /**
47 * Setup columns of the Grid dynamically based on a list of given cols.
48 * The function is called from the {@link Lada.controller.Filter#search
49 * search event}
50 * The Images for the Read-Write Icon are defined in CSS
51 */
52 setupColumns: function(cols) {
53 var caf = this.generateColumnsAndFields(cols);
54 var columns = caf[0];
55 var fields = caf[1];
56 this.store.model.setFields(fields);
57 this.reconfigure(this.store, columns);
58 },
59
60 /**
61 * generateColumnsAndFields
62 * generates an array of columns which are used for the dynamic grid
63 * @return an array of two arrays: [0] is an array of colums [1] an array
64 * of fields
65 **/
66 generateColumnsAndFields: function(cols) {
67 var resultColumns = [];
68 var fields = [];
69
70 fields.push(new Ext.data.Field({
71 name: 'owner'
72 }));
73 fields.push(new Ext.data.Field({
74 name: 'readonly'
75 }));
76
77 resultColumns.push({
78 xtype: 'actioncolumn',
79 text: 'RW',
80 dataIndex: 'readonly',
81 sortable: false,
82 tooltip: 'Probe öffnen',
83 width: 30,
84 getClass: function (val, meta, rec) {
85 return rec.get('readonly') === false ? "edit" : "noedit";
86 },
87 handler: function(grid, rowIndex, colIndex) {
88 var rec = grid.getStore().getAt(rowIndex);
89 grid.fireEvent('itemdblclick', grid, rec);
90 }
91 });
92
93 for (var i = cols.length - 1; i >= 0; i--) {
94 if (cols[i] === 'id') {
95 continue;
96 }
97 resultColumns.push(cols[i]);
98 fields.push(new Ext.data.Field({
99 name: cols[i].dataIndex
100 }));
101 }
102 var caf = new Array();
103 caf[0] = resultColumns;
104 caf[1] = fields;
105 return caf;
106 }
107 });
108

http://lada.wald.intevation.org