PDA

View Full Version : Combo box auto complete- Remote load



nityajs
13 Sep 2009, 5:43 PM
Hi,

Auto complete feature of combo box is not working for me. Here is my code for combo.


var statusCombo = new Ext.form.ComboBox({
typeAhead: true, triggerAction: 'all', lazyRender:true,
store: new Ext.data.JsonStore({
id: 0, root:'StatusSearch',
fields: [
{name:'myValue', mapping:'myValue'},
{name:'myMeaning', mapping:'myMeaning'}
],
url :contextPath + "/qs?op=getStatus"
}),
valueField: 'myValue',
displayField: 'myMeaning',
fieldLabel :'Status',
hiddenName: 'statusSearch',
anchor :'95%'
});



When I look at the drop down I get the list populated as Open, Closed, Pending. But When I start typing like 'Clos' I expect the combo to display the "Closed" value in list. But it doesnt. Could any one please let me know whats wrong with this code?

When I start typing the letters, server request call is made and combo is populated and default first value in list is selected but not the value matching my inputted letters.


Any help on this would be highly appreciated.

marcvs
14 Sep 2009, 3:41 AM
Hi nityajs (http://www.extjs.com/forum/member.php?u=81289),

I'm no expert here, but I'll share with you what I've found out since no one has replied yet and I am having the same problem.

I always get the first entry in the list regardless of what I have typed. In Firebug I noticed a POST being sent on each keypress (triggerAction). For this you set the mode to local in your combo configuration (default is remote).



...
hiddenName: 'statusSearch',
anchor :'95%',
mode: 'local'
});
If you set this, the combo will never do the POST for the data and the box remains empty. So load your store beforehand. I did remoteJsonStore.load(); but mine is defined separately. In your case I guess you could add .load at the end:



...
url :contextPath + "/qs?op=getStatus"
}).load(),
valueField: 'myValue',
You should see a single POST in Firebug and typeAhead should work, but this is only good if you have a small number of records (all records are stored locally in memory this way). My problem now is switching back to remote mode and use paging (pageSize) so that I don't read all the records at one go on each triggerAction. I will post this in a new thread if you want to keep an eye.

Mike Robinson
14 Sep 2009, 1:01 PM
The control will fire requests to the host with "query=" the partially-completed text. If no text, that parameter isn't there.

Apparently you have to return the right starting-value. Yourself.

(This is not authoritative information: this is what I've discovered by T&E.)

My advice is: load the combo, handle it locally. If it's so big that this won't work, then it probably shouldn't be a combo.