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:  * Combobox for Verwaltungseinheit
raimund@548:  */
raimund@548: Ext.define('Lada.view.widget.Verwaltungseinheit', {
raimund@548:     extend: 'Lada.view.widget.base.ComboBox',
raimund@598:     alias: 'widget.verwaltungseinheit',
raimund@548:     store: 'Verwaltungseinheiten',
raimund@548:     displayField: 'bezeichnung',
raimund@548:     valueField: 'id',
raimund@548:     emptyText: 'Wählen Sie eine Verwaltungseinheit',
raimund@548:     hideTrigger: true,
raimund@548:     // Enable filtering of comboboxes
raimund@548:     autoSelect: false,
raimund@548:     queryMode: 'remote',
raimund@548:     triggerAction: 'type',
raimund@548:     typeAhead: false,
raimund@548:     minChars: 2,
raimund@548: 
raimund@548:     initComponent: function() {
raimund@548:         this.store = Ext.data.StoreManager.get('verwaltungseinheiten');
raimund@548:         if (!this.store) {
raimund@548:             this.store = Ext.create('Lada.store.Verwaltungseinheiten');
raimund@548:         }
raimund@548:         this.callParent(arguments);
raimund@548:     },
raimund@548:     // This listener is used to load currently "selected" verwaltungseinheit.
raimund@548:     // This is needed as without having this record the field would only
raimund@548:     // display the raw value (id) of the verwaltungseinheit.
raimund@548:     listeners: {
raimund@548:         render: function(combo) {
raimund@548:             combo.store.load({
raimund@548:                 id: this.getValue()
raimund@548:             });
raimund@548:         }
raimund@548:     }
raimund@548: });