View Full Version : Combobox autocomplete to search the whole string in local mode

2 Sep 2012, 10:45 AM

I have a combobox in local mode with a list of names that could be either (FirstName LastName) or (LastName FirstName). I noticed that the autocomplete only searches strings that start with "string" instead of contains "string". Kind of '%string%' instead of 'string%' in mysql. Is there a way to do this in a local mode ?

2 Sep 2012, 6:13 PM
Try this:

var combo = Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Demo',
renderTo: Ext.getBody(),
multiSelect: false,
displayField: 'name',
width: 220,
labelWidth: 70,
store: {
fields: ['name'],
data: [{
name: 'John Smith'
name: 'Albert Einstein'
name: 'Thomas Edison'
name: 'John Deer'
queryMode: 'local',
listeners: {
beforequery: function(qe){
qe.query = new RegExp(qe.query, 'i');
qe.forceAll = true;


2 Sep 2012, 9:46 PM
This worked like a charm!!!
Thank you so much :)