View Full Version : ComboBox autocomplete with local mode - substring search instead of prefix match

4 Jul 2012, 3:42 AM
Hi, I have a combobox configured for autocompletion in queryMode: "local":

editor: {xtype: 'combobox', store: dataSrcSt, valueField: 'Id', displayField: 'Description', allowBlank: false, queryMode: 'local', typeAhead: true, minChars: 2}

And the autocomplete seems to work - it matches a correct entry if a prefix of the display value is entered. But what should I do to filter the entries by matching a substring anywhere in the display value ( 'displayValue like *typedText*', not 'like typedText*')

ExtJS 4.1


4 Jul 2012, 6:24 AM
You can try this:

Ext.onReady(function() {

var simpleCombo = Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Select a single state',
displayField: 'name',
valueField: 'abbr',
width: 320,
labelWidth: 130,
queryMode: 'local',
typeAhead: true,
minChars: 2,
name: 'agentDownline',
store: new Ext.data.SimpleStore({
fields: ['abbr', 'name', 'slogan'],
data: [
['VA', 'Virginia', 'Mother of States'],
['WA', 'Washington', 'Green Tree State'],
['WV', 'West Virginia', 'Mountain State'],
['WI', 'Wisconsin', 'America\'s Dairyland'],
['WY', 'Wyoming', 'Like No Place on Earth']
listeners: {
buffer: 50,
change: function() {
var store = this.store;
property: 'name',
anyMatch: true,
value : this.getValue()

Ext.create("Ext.Window", {
items: simpleCombo

Is that what you are looking for?

6 Jul 2012, 4:43 AM
Yes, that's the solution. Thanks!

11 Jul 2013, 11:26 PM
Thanks from me too, it helped me alot!!!

23 Jul 2013, 2:53 PM
The combobox has an extra property as of 4.1.3, it's called 'enableRegEx'. If the mode is local it will do the matching without having to listen for a change in this field.