comparison app/view/widget/DynamicGrid.js @ 1007:23bfcbdb4527

merged.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 20 Jan 2016 17:33:33 +0100
parents 7867752a0d58
children 52b02b0225e8
comparison
equal deleted inserted replaced
1002:54179b6043b6 1007:23bfcbdb4527
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 border: false,
18 multiSelect: true,
19 allowDeselect: true,
20
21 isDynamic: true,
22
23 viewConfig: {
24 deferEmptyText: false
25 },
26
27 initComponent: function() {
28 var i18n = Lada.getApplication().bundle;
29 this.callParent(arguments);
30 },
31
32 /**
33 * This sets the Store of the DynamicGrid
34 */
35 setStore: function(store){
36 var i18n = Lada.getApplication().bundle;
37
38 this.removeDocked(Ext.getCmp('ptbar'), true);
39 this.reconfigure(store);
40 this.addDocked([{
41 xtype: 'pagingtoolbar',
42 id: 'ptbar',
43 dock: 'bottom',
44 store: store,
45 displayInfo: true
46 }]);
47
48 },
49
50 /**
51 * Setup columns of the Grid dynamically based on a list of given cols.
52 * The function is called from the {@link Lada.controller.Filter#search
53 * search event}
54 * The Images for the Read-Write Icon are defined in CSS
55 */
56 setupColumns: function(cols) {
57 var caf = this.generateColumnsAndFields(cols);
58 var columns = caf[0];
59 var fields = caf[1];
60 this.store.model.setFields(fields);
61 this.reconfigure(this.store, columns);
62 },
63
64 /**
65 * generateColumnsAndFields
66 * generates an array of columns which are used for the dynamic grid
67 * @return an array of two arrays: [0] is an array of colums [1] an array
68 * of fields
69 **/
70 generateColumnsAndFields: function(cols) {
71 var resultColumns = [];
72 var fields = [];
73
74 fields.push(new Ext.data.Field({
75 name: 'owner'
76 }));
77 fields.push(new Ext.data.Field({
78 name: 'readonly'
79 }));
80
81 resultColumns.push({
82 xtype: 'actioncolumn',
83 text: 'RW',
84 dataIndex: 'readonly',
85 sortable: false,
86 tooltip: 'Probe öffnen',
87 width: 30,
88 getClass: function (val, meta, rec) {
89 return rec.get('readonly') === false ? "edit" : "noedit";
90 },
91 handler: function(grid, rowIndex, colIndex) {
92 var rec = grid.getStore().getAt(rowIndex);
93 grid.fireEvent('itemdblclick', grid, rec);
94 }
95 });
96
97 for (var i = cols.length - 1; i >= 0; i--) {
98 if (cols[i] === 'id') {
99 continue;
100 }
101 resultColumns.push(cols[i]);
102 fields.push(new Ext.data.Field({
103 name: cols[i].dataIndex
104 }));
105 }
106 var caf = new Array();
107 caf[0] = resultColumns;
108 caf[1] = fields;
109 return caf;
110 }
111 });
112

http://lada.wald.intevation.org