raimund@596: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@596: * Software engineering by Intevation GmbH raimund@596: * raimund@596: * This file is Free Software under the GNU GPL (v>=3) raimund@596: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@596: * the documentation coming with IMIS-Labordaten-Application for details. raimund@596: */ raimund@596: raimund@596: /* raimund@596: * Grid to list Kommentare for Messunge raimund@596: */ raimund@596: Ext.define('Lada.view.grid.MKommentar', { raimund@596: extend: 'Ext.grid.Panel', raimund@596: alias: 'widget.mkommentargrid', raimund@596: raimund@596: maxHeight: 350, raimund@596: emptyText: 'Keine Kommentare gefunden.', raimund@596: minHeight: 110, raimund@596: viewConfig: { raimund@596: deferEmptyText: false raimund@596: }, raimund@596: raimund@596: recordId: null, raimund@596: raimund@596: initComponent: function() { raimund@596: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { raimund@596: clicksToMoveEditor: 1, dustin@683: autoCancel: false, dustin@703: disabled: 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@703: // But the RowEditPlugin is not handled there. dustin@683: beforeedit: function(e, o) { dustin@703: var readonlywin = o.grid.up('window').record.get('readonly'); dustin@703: var readonlygrid = o.record.get('readonly'); dustin@703: if (readonlywin == true || readonlygrid == true || this.disabled) { dustin@683: return false; dustin@683: } dustin@683: return true; dustin@683: } dustin@683: } dustin@703: }); raimund@596: this.plugins = [this.rowEditing]; raimund@596: this.dockedItems = [{ raimund@596: xtype: 'toolbar', raimund@596: dock: 'bottom', raimund@596: items: ['->', { raimund@596: text: 'Hinzufügen', raimund@596: icon: 'resources/img/list-add.png', raimund@596: action: 'add' raimund@596: }, { raimund@596: text: 'Löschen', raimund@596: icon: 'resources/img/list-remove.png', raimund@596: action: 'delete' raimund@596: }] raimund@596: }]; raimund@596: this.columns = [{ raimund@596: header: 'Erzeuger', raimund@596: dataIndex: 'erzeuger', raimund@596: renderer: function(value) { raimund@596: if (!value || value === '') { raimund@596: return ''; raimund@596: } raimund@596: var mstore = Ext.data.StoreManager.get('messstellen'); raimund@596: return mstore.getById(value).get('messStelle'); raimund@596: }, raimund@596: editor: { raimund@596: xtype: 'combobox', raimund@596: store: Ext.data.StoreManager.get('messstellen'), raimund@596: displayField: 'messStelle', raimund@596: valueField: 'id', dustin@664: allowBlank: false, dustin@718: editable: false raimund@596: } raimund@596: }, { raimund@596: header: 'Datum', raimund@596: dataIndex: 'datum', dustin@626: xtype: 'datecolumn', dustin@664: format: 'd.m.Y', raimund@596: editor: { raimund@596: xtype: 'datefield', raimund@596: allowBlank: false, dustin@664: format: 'd.m.Y', dustin@664: maxValue: Ext.Date.format(new Date(), 'd.m.Y') raimund@596: } raimund@596: }, { raimund@596: header: 'Text', raimund@596: dataIndex: 'text', raimund@596: flex: 1, raimund@596: editor: { dustin@664: allowBlank: false, dustin@664: maxLength: 1000, dustin@664: enforceMaxLength: true raimund@596: } raimund@596: }]; raimund@596: this.initData(); raimund@596: this.callParent(arguments); raimund@596: }, raimund@596: raimund@596: initData: function() { raimund@596: if (this.store) { raimund@596: this.store.removeAll(); raimund@596: } raimund@596: else { raimund@596: this.store = Ext.create('Lada.store.MKommentare'); raimund@596: } raimund@596: this.store.load({ raimund@596: params: { raimund@596: messungsId: this.recordId raimund@596: } raimund@596: }); 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@596: } raimund@596: });