PDA

View Full Version : Autocomplete and remote combobox issue



douggiefox
10 Mar 2010, 7:30 AM
Hi

I've defined a remote combobox in the following way:


var postcodetemplate = new Ext.XTemplate(
'<tpl for="."><div class="postcode-combo-result-item">',
'<div class="combo-code">{code}</div>',
'<div class="combo-full-description">{town}, District: {district}</div>',
'</div></tpl>'
);

new Ext.data.Store({
id: 'postcodes',
url: 'postcode/listAsJSON',
reader: new Ext.data.JsonReader({
root:'items',
totalProperty: 'totalCount',
fields:[
{name:'id'},
{name:'code'},
{name:'town'},
{name:'district', mapping: 'district.description'},
{name:'fulldescription'}
]
})
});

var postcodeCombo = new Ext.form.ComboBox({
ref: '../../postcodeCombo',
autoComplete: true,
forceSelection: true,
itemId: 'postcodeCombo',
minChars: 1,
mode: 'remote',
allowBlank: false,
anchor: "85%",
store: 'postcodes',
displayField: 'code',
fieldLabel:'Postcode',
typeAhead: true,
triggerAction: 'all',
emptyText:'Select a postcode...',
selectOnFocus:true,
valueField: 'id',
hiddenName: 'quotationTypeId',
tpl: postcodetemplate,
itemSelector : 'div.postcode-combo-result-item',
pageSize: 10,
tabIndex: 11
});



All my results are 1 or 2 characters long. So I might have "S" or "SA" or "D" or "DS"...

If I type in a single character and the first matching result is 2 characters long, autocomplete kicks in and the value is selected. However, if the first matching result is only 1 character long, autocomplete doesn't seem to kick in and I have to physically select from the list. It seems inconsistent. Has anyone else seen this?

Best

DF