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 Probenzusatzwerte raimund@548: */ raimund@548: Ext.define('Lada.view.grid.Probenzusatzwert', { raimund@548: extend: 'Ext.grid.Panel', raimund@548: alias: 'widget.probenzusatzwertgrid', raimund@548: requires: [ raimund@548: 'Lada.view.widget.Probenzusatzwert' raimund@548: ], raimund@548: raimund@548: maxHeight: 350, raimund@548: emptyText: 'Keine Zusatzwerte gefunden.', raimund@548: minHeight: 110, raimund@548: viewConfig: { raimund@548: deferEmptyText: false raimund@548: }, raimund@548: margin: '0, 5, 5, 5', raimund@548: raimund@548: recordId: null, raimund@548: raimund@548: initComponent: function() { raimund@571: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { raimund@548: clicksToMoveEditor: 1, dustin@683: autoCancel: false, dustin@684: pluginId: 'rowedit', dustin@683: listeners:{ dustin@683: // Make row ineditable when readonly is set to true dustin@683: // Normally this would belong into a controller an not the view. dustin@702: // But the RowEditPlugin is not handled there. dustin@683: beforeedit: function(e, o) { dustin@702: var readonlywin = o.grid.up('window').record.get('readonly'); dustin@702: var readonlygrid = o.record.get('readonly'); dustin@702: if (readonlywin == true || readonlygrid == true) { dustin@683: return false; dustin@683: } dustin@683: return true; dustin@683: } dustin@683: } raimund@548: }); raimund@571: this.plugins = [this.rowEditing]; raimund@548: this.dockedItems = [{ raimund@548: xtype: 'toolbar', raimund@548: dock: 'bottom', raimund@548: items: ['->', { raimund@548: text: 'Hinzufügen', raimund@548: icon: 'resources/img/list-add.png', raimund@548: action: 'add', raimund@548: probeId: this.probeId raimund@548: }, { raimund@548: text: 'Löschen', raimund@548: icon: 'resources/img/list-remove.png', raimund@548: action: 'delete' raimund@548: }] raimund@548: }]; raimund@548: this.columns = [{ raimund@548: header: 'PZW-ID', raimund@548: dataIndex: 'id', dustin@625: flex: 1, raimund@548: }, { raimund@548: header: 'PZW-Größe', raimund@548: dataIndex: 'pzsId', dustin@625: flex: 3, raimund@548: renderer: function(value) { raimund@571: if (!value || value === '') { raimund@571: return ''; raimund@571: } raimund@548: var store = Ext.data.StoreManager.get('probenzusaetze'); raimund@548: var record = store.getById(value); raimund@548: return record.get('beschreibung'); raimund@548: }, raimund@548: editor: { raimund@559: xtype: 'combobox', raimund@559: store: Ext.data.StoreManager.get('probenzusaetze'), raimund@559: displayField: 'beschreibung', raimund@559: valueField: 'id', dustin@665: allowBlank: false, dustin@665: editable: false raimund@548: } raimund@548: }, { raimund@548: header: 'Messwert', raimund@559: dataIndex: 'messwertPzs', dustin@625: xtype: 'numbercolumn', dustin@625: flex: 1, raimund@559: editor: { dustin@625: xtype: 'numberfield', dustin@665: allowBlank: false, dustin@665: maxLength: 10, dustin@665: enforceMaxLength: true, dustin@665: allowExponential: false dustin@665: } dustin@665: }, { dustin@665: header: '< NWG', dustin@665: flex: 1, dustin@665: renderer: function(value, meta, record) { dustin@665: var nwg = record.get('nwgZuMesswert'); dustin@665: var mw = record.get('messwertPzs'); dustin@665: if ( mw < nwg) { dustin@665: return '<'; dustin@665: } dustin@665: return ''; dustin@665: } dustin@665: }, { dustin@665: header: 'Nachweisgrenze', dustin@665: dataIndex: 'nwgZuMesswert', dustin@665: xtype: 'numbercolumn', dustin@665: format: '0', dustin@665: flex: 1, dustin@665: editor: { dustin@665: xtype: 'numberfield', dustin@665: allowBlank: false, dustin@665: maxLength: 10, dustin@665: enforceMaxLength: true, dustin@665: allowExponential: false raimund@559: } raimund@559: }, { raimund@559: header: 'Maßeinheit', raimund@559: dataIndex: 'pzsId', dustin@625: flex: 1, raimund@548: renderer: function(value) { raimund@571: if (!value || value === '') { raimund@571: return ''; raimund@571: } raimund@559: var zstore = Ext.data.StoreManager.get('probenzusaetze'); raimund@559: var mstore = Ext.data.StoreManager.get('messeinheiten'); raimund@559: var mehId = zstore.getById(value).get('mehId'); raimund@559: var record = mstore.findRecord('id', mehId); raimund@559: return record.get('einheit'); raimund@559: } raimund@559: }, { raimund@548: header: 'rel. Unsich.[%]', raimund@548: dataIndex: 'messfehler', dustin@625: xtype: 'numbercolumn', dustin@625: format: '0', dustin@625: flex: 1, raimund@548: editor: { dustin@625: xtype: 'numberfield', dustin@665: allowBlank: false, dustin@665: maxLength: 3, dustin@665: enforceMaxLength: true, dustin@665: allowExponential: false, dustin@665: allowDecimal: false dustin@625: } raimund@548: }]; raimund@548: this.initData(); raimund@548: this.callParent(arguments); raimund@548: }, raimund@548: raimund@548: initData: function() { raimund@548: this.store = Ext.create('Lada.store.Zusatzwerte'); raimund@548: this.store.load({ raimund@548: params: { raimund@548: probeId: this.recordId raimund@548: } raimund@548: }); dustin@684: }, dustin@684: dustin@684: setReadOnly: function(b) { dustin@684: if (b == true){ dustin@684: //Readonly dustin@684: if (this.getPlugin('rowedit')){ dustin@684: this.getPlugin('rowedit').disable(); dustin@684: } dustin@684: this.down('button[action=delete]').disable(); dustin@684: this.down('button[action=add]').disable(); dustin@684: }else{ dustin@684: //Writable dustin@684: if (this.getPlugin('rowedit')){ dustin@684: this.getPlugin('rowedit').enable(); dustin@684: } dustin@684: this.down('button[action=delete]').enable(); dustin@684: this.down('button[action=add]').enable(); dustin@684: } raimund@548: } raimund@548: });