view app/view/grid/Probenzusatzwert.js @ 639:fdaabab6f4cc

Open Probe-/Messung-Edit window automatically if a new item was saved successfully.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 Mar 2015 14:44:52 +0100
parents f59bda7551d7
children 4a9bd2664da6
line wrap: on
line source
/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out
 * the documentation coming with IMIS-Labordaten-Application for details.
 */

/*
 * Grid to list Probenzusatzwerte
 */
Ext.define('Lada.view.grid.Probenzusatzwert', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.probenzusatzwertgrid',
    requires: [
        'Lada.view.widget.Probenzusatzwert'
    ],

    maxHeight: 350,
    emptyText: 'Keine Zusatzwerte gefunden.',
    minHeight: 110,
    viewConfig: {
        deferEmptyText: false
    },
    margin: '0, 5, 5, 5',

    recordId: null,

    initComponent: function() {
        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
            clicksToMoveEditor: 1,
            autoCancel: false
        });
        this.plugins = [this.rowEditing];
        this.dockedItems = [{
            xtype: 'toolbar',
            dock: 'bottom',
            items: ['->', {
                text: 'Hinzufügen',
                icon: 'resources/img/list-add.png',
                action: 'add',
                probeId: this.probeId
            }, {
                text: 'Löschen',
                icon: 'resources/img/list-remove.png',
                action: 'delete'
            }]
        }];
        this.columns = [{
            header: 'PZW-ID',
            dataIndex: 'id',
            flex: 1,
        }, {
            header: 'PZW-Größe',
            dataIndex: 'pzsId',
            flex: 3,
            renderer: function(value) {
                if (!value || value === '') {
                    return '';
                }
                var store = Ext.data.StoreManager.get('probenzusaetze');
                var record = store.getById(value);
                return record.get('beschreibung');
            },
            editor: {
                xtype: 'combobox',
                store: Ext.data.StoreManager.get('probenzusaetze'),
                displayField: 'beschreibung',
                valueField: 'id',
                allowBlank: false
            }
        }, {
            header: 'Messwert',
            dataIndex: 'messwertPzs',
            xtype: 'numbercolumn',
            flex: 1,
            editor: {
                xtype: 'numberfield',
                allowBlank: false
            }
        }, {
            header: 'Maßeinheit',
            dataIndex: 'pzsId',
            flex: 1,
            renderer: function(value) {
                if (!value || value === '') {
                    return '';
                }
                var zstore = Ext.data.StoreManager.get('probenzusaetze');
                var mstore = Ext.data.StoreManager.get('messeinheiten');
                var mehId = zstore.getById(value).get('mehId');
                var record = mstore.findRecord('id', mehId);
                return record.get('einheit');
            }
        }, {
            header: 'Nachweisgrenze',
            dataIndex: 'nwgZuMesswert',
            xtype: 'numbercolumn',
            format: '0',
            flex: 1,
            editor: {
                xtype: 'numberfield',
                allowBlank: false
            }
        }, {
            header: 'rel. Unsich.[%]',
            dataIndex: 'messfehler',
            xtype: 'numbercolumn',
            format: '0',
            flex: 1,
            editor: {
                xtype: 'numberfield',
                allowBlank: false
            }
        }, {
            header: '< NWG',
            flex: 1,
            renderer: function(value, meta, record) {
                var nwg = record.get('nwgZuMesswert');
                var mw = record.get('messwertPzs');
                if ( mw < nwg) {
                    return 'MW < NWG';
                }
                return '';
            }
        }];
        this.initData();
        this.callParent(arguments);
    },

    initData: function() {
        this.store = Ext.create('Lada.store.Zusatzwerte');
        this.store.load({
            params: {
                probeId: this.recordId
            }
        });
    }
});

http://lada.wald.intevation.org