Ext.ux.userDbField = function(config) {
  config.store = new Ext.data.Store({
    proxy: new Ext.data.ScriptTagProxy({ url: "index.php?ajaxPhpScriptId=" + config.ajaxId + (config.groupId && config.groupId.length>0?"&groupId="+config.groupId:"") }),
    reader: new Ext.data.JsonReader({
      root: "rows", totalProperty: "totalCount", id: "id"
    }, [ {name: "id"}, {name: "name"}, {name: "vorname"}, {name: "nameVorname"} ])
  });
  config.minChars = 1;
  config.displayField = 'nameVorname';
  config.valueField = 'id';
  config.typeAhead = false;
  config.selectOnFocus = true;
  config.forceSelection = true;
  config.pageSize = 10;
  config.listWidth = 237;
  config.queryDelay = 100;
  config.hideTrigger = true;
  config.tpl = new Ext.XTemplate('<tpl for="."><div class="search-item" style="padding:2px;">{nameVorname}</div></tpl>');
  config.itemSelector = 'div.search-item';

  // nötig damit blank auch akzeptiert wird
    if (config.allowBlank !== false) {
      config.allowBlank = true;
      config.enableKeyEvents = true;
      if (typeof(config.listeners) != "object") config.listeners = {};
      if (typeof(config.listeners.blur) != "function")
        config.listeners.blur = function (field) { if (this.getRawValue() == "") {
          this.setValue("");
          if (typeof(this.initialConfig.listeners.change) == "function") this.fireEvent('change', this, "", "");
        } };
      if (typeof(config.listeners.keydown) != "function")
        config.listeners.keydown = function (field, e) { if (e.getKey()==e.ENTER && this.getRawValue() == "") { // ENTER-Key (weil BLUR nicht ausgelöst wird in EditGrids wenn nach bearbeitung ENTER gedrückt wird)
          this.setValue("");
          if (typeof(this.initialConfig.listeners.change) == "function") this.fireEvent('change', this, "", "");
        } };
    }

  if (typeof(dbGetValueRendererArr) != "undefined")
    config.onSelect = function(record) {
      if (typeof(dbGetValueRendererArr[this.initialConfig.column]) != "array") dbGetValueRendererArr[this.initialConfig.column] = new Array();
      dbGetValueRendererArr[this.initialConfig.column][record.data.id] = record.data.nameVorname;
      this.setValue(record.data.id);
      this.collapse();
    }

  Ext.ux.userDbField.superclass.constructor.call(this, config);
};

Ext.extend(Ext.ux.userDbField, Ext.form.ComboBox, {});
