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:
dustin@751: store: null, //'ProbenList',
raimund@548:
raimund@548: multiSelect: true,
raimund@548:
raimund@548: viewConfig: {
dustin@753: emptyText: 'Keine Ergebnisse 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: [{
dustin@753: xtype: 'tbtext',
dustin@753: id: 'tbtitle',
dustin@753: text: '',
dustin@753: },
dustin@753: '->',
dustin@753: {
dustin@753: text: 'Probe erstellen',
raimund@548: icon: 'resources/img/list-add.png',
dustin@753: action: 'addProbe'
raimund@548: }, {
dustin@753: text: 'Messprogramm erstellen',
dustin@753: icon: 'resources/img/list-add.png',
dustin@755: action: 'addMessprogramm'
dustin@753: },
dustin@753: '-',
dustin@753: {
dustin@753: text: 'Proben Importieren',
raimund@548: icon: 'resources/img/svn-commit.png',
raimund@548: action: 'import'
raimund@548: }, {
dustin@753: text: 'Proben Exportieren',
raimund@548: icon: 'resources/img/svn-update.png',
raimund@548: action: 'export'
dustin@753: }
dustin@753: ]
raimund@548: }];
raimund@548: this.columns = [];
raimund@548: this.callParent(arguments);
raimund@548: },
raimund@548:
raimund@548: /**
dustin@751: * This sets the Store of the FilterResultGrid
dustin@751: */
dustin@751: setStore: function(store){
dustin@753: var i18n = Lada.getApplication().bundle;
dustin@753:
dustin@751: this.removeDocked(Ext.getCmp('ptbar'), true);
dustin@751: this.reconfigure(store);
dustin@751: this.addDocked([{
dustin@751: xtype: 'pagingtoolbar',
dustin@751: id: 'ptbar',
dustin@751: dock: 'bottom',
dustin@751: store: store,
dustin@751: displayInfo: true
dustin@751: }]);
dustin@753:
dustin@753: //Reset the Text int the Toolbar.
dustin@753: var t = Ext.getCmp('tbtitle');
dustin@753: if (store.model.modelName == 'Lada.model.MessprogrammList') {
dustin@753: t.setText(i18n.getMsg('probeplanning'));
dustin@753: }
dustin@753: else if (store.model.modelName == 'Lada.model.ProbeList') {
dustin@753: t.setText(i18n.getMsg('probelist'));
dustin@753: }
dustin@753: else {
dustin@753: t.setText('');
dustin@753: console.log('The model '+store.model.modelName+
dustin@753: 'was not defined in the FilterResultGrid.' +
dustin@753: ' Hence the title could not be set.');
dustin@753: }
dustin@751: },
dustin@751: /**
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',
dustin@682: sortable: false,
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: });