PDA

View Full Version : Autocomplete combobox



MrTim
20 Nov 2009, 1:36 AM
Hey guys.

I have an auto complete combobox running off of a remote jsonstore. When i free type into the combo it defaults to the top record. This only happens when the item is not in the list. If wat i hgav etyped in the combo is in the list it works fine.



Ext.namespace("AIMS.Custom");
AIMS.Custom.AutoCombo = function(config) {
// Properties
this.grpObjectId = config.GroupId || -1;
this.fieldLabel = config.FieldLabel || '';
this.emptyText = config.EmptyText || 'Select...';
this.minChars = config.StartSearchAt || 4;
this.hideTrigger = config.HideTrigger || false;
this.anchor = config.Anchor;
this.width = config.Width;
this.optionalParam = config.optionalParam;
this.lazyRender = true;
this.mode = 'remote';
this.triggerAction = 'all';
this.editable = true;
this.displayField = config.displayField || 'objectName';
this.valueField = config.valueField || 'objectId';
// this.tpl = new Ext.XTemplate('<tpl for="."><div class="search-objectname">{objectName} ({objectId})</div></tpl>');
this.selectOnFocus = false;
this.typeAhead = false;
this.name = config.name;
this.hiddenName = config.HiddenName || 'comboValue';

this.store = new Ext.data.JsonStore({
idProperty: 0,
autoLoad: true,
url: AimsDataUrl,
root: 'data',
totalProperty: 'totalCount',
baseParams: {
'cmd': 'custom-combo',
'grpObjectId': this.grpObjectId,
'optionalParam': this.optionalParam
},
fields: [
{ name: 'objectId', type: 'int' },
'objectName'
]
});
AIMS.Custom.AutoCombo.superclass.constructor.call(this, config);
this.setOptionalParam = function(param) {
this.optionalParam = param;
this.store.baseParams.optionalParam = param;
this.store.reload();
};
};
Ext.extend(AIMS.Custom.AutoCombo, Ext.form.ComboBox, {});