dustin@764: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@764: * Software engineering by Intevation GmbH dustin@764: * dustin@764: * This file is Free Software under the GNU GPL (v>=3) dustin@764: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@764: * the documentation coming with IMIS-Labordaten-Application for details. dustin@764: */ dustin@764: dustin@764: /* dustin@764: * Grid to list Nuklide dustin@764: */ dustin@764: Ext.define('Lada.view.grid.Nuklide', { dustin@764: extend: 'Ext.grid.Panel', dustin@764: alias: 'widget.nuklidegrid', dustin@764: dustin@764: requires: [ dustin@764: 'Lada.view.widget.Messgroesse' dustin@764: ], dustin@764: dustin@767: maxHeight: 150, dustin@767: minHeight: 150, dustin@764: viewConfig: { dustin@767: deferEmptyText: false, dustin@767: markDirty: false //Remove Dirty-Flags dustin@764: }, dustin@768: margin: '0, 0, 5, 5', dustin@764: dustin@764: recordId: null, dustin@768: allowDeselect: true, dustin@764: dustin@764: initComponent: function() { dustin@764: var i18n = Lada.getApplication().bundle; dustin@764: this.emptyText = i18n.getMsg('emptytext.nuklidgrid'); dustin@764: dustin@764: this.dockedItems = [{ dustin@764: xtype: 'toolbar', dustin@764: dock: 'bottom', dustin@764: items: ['->', { dustin@766: text: i18n.getMsg('add'), dustin@766: qtip: i18n.getMsg('add.qtip'), dustin@766: icon: 'resources/img/list-add.png', dustin@766: action: 'add', dustin@764: disabled: true dustin@764: }, { dustin@766: text: i18n.getMsg('delete'), dustin@766: qtip: i18n.getMsg('delete.qtip'), dustin@766: icon: 'resources/img/list-remove.png', dustin@766: action: 'remove', dustin@764: disabled: true dustin@764: }] dustin@764: }]; dustin@764: this.columns = [{ dustin@764: header: i18n.getMsg('nuklid'), dustin@764: dataIndex: 'id', dustin@764: flex: 1, dustin@764: renderer: function(value) { dustin@764: if (!value || value === '') { dustin@764: return ''; dustin@764: } dustin@764: var store = Ext.data.StoreManager.get('messgroessen'); dustin@764: if (!store) { dustin@764: store = Ext.create('Lada.store.Messgroessen'); dustin@764: } dustin@764: return store.findRecord('id', value, 0, false, false, true).get('messgroesse'); dustin@766: }, dustin@766: editor: { dustin@766: xtype: 'combobox', dustin@766: store: Ext.data.StoreManager.get('messgroessen'), dustin@766: valueField: 'id', dustin@766: allowBlank: false, dustin@766: editable: true, dustin@766: forceSelection: true, dustin@766: autoSelect: true, dustin@766: //multiSelect: true, // TODO dustin@766: queryMode: 'local', dustin@766: minChars: 0, dustin@766: typeAhead: false, dustin@766: triggerAction: 'all', dustin@766: tpl: Ext.create("Ext.XTemplate", dustin@766: '' + dustin@766: '{messgroesse}'), dustin@766: displayTpl: Ext.create('Ext.XTemplate', dustin@766: '{messgroesse}'), dustin@764: } dustin@764: }]; dustin@766: dustin@766: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { dustin@766: clicksToMoveEditor: 1, dustin@766: autoCancel: false, dustin@766: disabled: false, dustin@766: pluginId: 'nuklidrowedit', dustin@766: listeners:{ dustin@766: // Make row ineditable when readonly is set to true dustin@766: // Normally this would belong into a controller an not the view. dustin@766: // But the RowEditPlugin is not handled there. dustin@766: beforeedit: function(e, o) { dustin@766: var readonlywin = o.grid.up('window').record.get('readonly'); dustin@766: var readonlygrid = o.record.get('readonly'); dustin@766: if (readonlywin == true || readonlygrid == true || this.disabled) { dustin@766: return false; dustin@766: } dustin@766: return true; dustin@766: } dustin@766: } dustin@766: }); dustin@766: dustin@766: this.plugins = [this.rowEditing]; dustin@766: dustin@764: this.initData(); dustin@764: this.callParent(arguments); dustin@764: }, dustin@764: initData: function() { dustin@764: if (this.store) { dustin@768: this.store.removeAll(); dustin@764: } dustin@764: }, dustin@764: setData: function(store) { dustin@764: this.setLoading(true); dustin@764: this.reconfigure(store); dustin@764: this.setLoading(false); dustin@764: }, dustin@764: setReadOnly: function(b) { dustin@764: if (b == true){ dustin@764: //Readonly dustin@764: if (this.getPlugin('rowedit')){ dustin@764: this.getPlugin('rowedit').disable(); dustin@764: } dustin@766: this.down('button[action=add]').disable(); dustin@766: this.down('button[action=remove]').disable(); dustin@764: }else{ dustin@764: //Writable dustin@764: if (this.getPlugin('rowedit')){ dustin@764: this.getPlugin('rowedit').enable(); dustin@764: } dustin@766: this.down('button[action=add]').enable(); dustin@766: this.down('button[action=remove]').enable(); dustin@764: } dustin@764: } dustin@764: });