raimund@548: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@548: * Software engineering by Intevation GmbH raimund@548: * raimund@548: * This file is Free Software under the GNU GPL (v>=3) raimund@548: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@548: * the documentation coming with IMIS-Labordaten-Application for details. raimund@548: */ raimund@548: raimund@548: /* raimund@548: * Grid to list Proben raimund@548: */ raimund@548: Ext.define('Lada.view.grid.FilterResult', { raimund@548: extend: 'Ext.grid.Panel', raimund@548: alias: 'widget.filterresultgrid', raimund@548: raimund@548: store: 'ProbenList', raimund@548: raimund@548: multiSelect: true, raimund@548: raimund@548: viewConfig: { raimund@548: emptyText: 'Keine Proben gefunden.', raimund@548: deferEmptyText: false raimund@548: }, raimund@548: raimund@548: initComponent: function() { raimund@548: this.dockedItems = [{ raimund@548: xtype: 'toolbar', raimund@548: dock: 'top', raimund@548: items: [{ raimund@548: text: 'Hinzufügen', raimund@548: icon: 'resources/img/list-add.png', raimund@548: action: 'add' raimund@548: }, { raimund@548: text: 'Import', raimund@548: icon: 'resources/img/svn-commit.png', raimund@548: action: 'import' raimund@548: }, { raimund@548: text: 'Export', raimund@548: icon: 'resources/img/svn-update.png', raimund@548: action: 'export' raimund@548: }] dustin@648: }, { dustin@648: xtype: 'pagingtoolbar', dustin@648: dock: 'bottom', dustin@656: store: this.store, dustin@648: displayInfo: true raimund@548: }]; raimund@548: this.columns = []; raimund@548: this.callParent(arguments); raimund@548: }, raimund@548: raimund@548: /** raimund@548: * Setup columns of the Grid dynamically based on a list of given cols. raimund@548: * The function is called from the {@link Lada.controller.Sql#selectSql raimund@548: * select sql event} raimund@548: */ raimund@548: setupColumns: function(cols) { raimund@548: var resultColumns = []; raimund@548: var fields = []; raimund@548: raimund@548: resultColumns.push({ raimund@548: header: 'RW', raimund@548: dataIndex: 'readonly', raimund@548: width: 30, raimund@548: renderer: function(value) { raimund@548: if (value) { raimund@548: return ''; raimund@548: } raimund@548: return ''; raimund@548: } raimund@548: }); raimund@548: fields.push(new Ext.data.Field({ raimund@548: name: 'readonly' raimund@548: })); raimund@548: for (var i = cols.length - 1; i >= 0; i--) { raimund@548: if (cols[i] === 'id') { raimund@548: continue; raimund@548: } raimund@548: resultColumns.push(cols[i]); raimund@548: fields.push(new Ext.data.Field({ raimund@548: name: cols[i].dataIndex raimund@548: })); raimund@548: } raimund@548: this.store.model.setFields(fields); raimund@548: this.reconfigure(this.store, resultColumns); raimund@548: } raimund@548: });