torsten@472: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
torsten@472: * Software engineering by Intevation GmbH
torsten@472: *
torsten@472: * This file is Free Software under the GNU GPL (v>=3)
torsten@472: * and comes with ABSOLUTELY NO WARRANTY! Check out
torsten@472: * the documentation coming with IMIS-Labordaten-Application for details.
torsten@472: */
torsten@472:
torsten@348: /*
torsten@348: * Grid to list Proben
torsten@348: */
torsten@4: Ext.define('Lada.view.proben.List' ,{
torsten@4: extend: 'Ext.grid.Panel',
torsten@4: alias: 'widget.probenlist',
raimund@491:
torsten@374: store: 'ProbenList',
rrenkert@400: multiSelect: true,
torsten@37: viewConfig: {
torsten@37: emptyText: 'Keine Proben gefunden.',
torsten@37: deferEmptyText: false
torsten@37: },
raimund@491:
torsten@4: initComponent: function() {
raimund@491: this.dockedItems = [{
raimund@491: xtype: 'toolbar',
raimund@491: dock: 'top',
raimund@491: items: [{
raimund@491: text: 'Hinzufügen',
raimund@491: icon: 'gfx/list-add.png',
raimund@491: action: 'add'
raimund@491: }, {
raimund@491: text: 'Import',
raimund@491: icon: 'gfx/svn-commit.png',
raimund@491: action: 'import'
raimund@491: }, {
raimund@491: text: 'Export',
raimund@491: icon: 'gfx/svn-update.png',
raimund@491: action: 'export'
raimund@491: }]
raimund@491: }];
torsten@238: this.columns = [];
torsten@4: this.callParent(arguments);
torsten@239: },
raimund@491:
torsten@348: /**
torsten@348: * Setup columns of the Grid dynamically based on a list of given cols.
torsten@353: * The function is called from the {@link Lada.controller.Sql#selectSql
torsten@348: * select sql event}
torsten@348: * @parameter {Array} List of cols to show in the Grid.
torsten@348: */
torsten@249: setupColumns: function(cols) {
torsten@364: var rcols = [];
torsten@374: var mfields = [];
torsten@374:
raimund@491: rcols.push({
raimund@491: header: 'RW',
raimund@491: dataIndex: 'readonly',
raimund@491: width: 30,
raimund@491: renderer: render_readonly
raimund@491: });
torsten@374: mfields.push(new Ext.data.Field({name: 'readonly'}));
torsten@249: for (var i = cols.length - 1; i >= 0; i--){
torsten@249: rcols.push(cols[i]);
raimund@491: mfields.push(new Ext.data.Field({
raimund@491: name: cols[i].dataIndex
raimund@491: }));
torsten@364: }
torsten@374: this.store.model.setFields(mfields);
torsten@249: this.reconfigure(this.store, rcols);
torsten@4: }
torsten@4: });
torsten@258:
torsten@348: /**
torsten@348: * Helper function to render a readonly symbol per row in the grid
torsten@348: * @param {Boolean} flag if the symbol is a readonly symbol.
torsten@348: */
torsten@258: function render_readonly (value) {
torsten@258: if (value) {
torsten@363: return '';
torsten@258: } else {
torsten@363: return '';
torsten@258: }
torsten@258: }