-
4 Jul 2012 3:42 AM #1
Answered: ComboBox autocomplete with local mode - substring search instead of prefix match
Answered: ComboBox autocomplete with local mode - substring search instead of prefix match
Hi, I have a combobox configured for autocompletion in queryMode: "local":
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*')Code:editor: {xtype: 'combobox', store: dataSrcSt, valueField: 'Id', displayField: 'Description', allowBlank: false, queryMode: 'local', typeAhead: true, minChars: 2}
ExtJS 4.1
Thanks
RG
-
Best Answer Posted by Romick
You can try this:
Is that what you are looking for?PHP Code: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;
//store.suspendEvents();
store.clearFilter();
//store.resumeEvents();
store.filter({
property: 'name',
anyMatch: true,
value : this.getValue()
});
}
}
});
Ext.create("Ext.Window", {
items: simpleCombo
}).show();
-
4 Jul 2012 6:24 AM #2
Hii
Hii
You can try this:
Is that what you are looking for?PHP Code: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;
//store.suspendEvents();
store.clearFilter();
//store.resumeEvents();
store.filter({
property: 'name',
anyMatch: true,
value : this.getValue()
});
}
}
});
Ext.create("Ext.Window", {
items: simpleCombo
}).show();
-
6 Jul 2012 4:43 AM #3
Yes, that's the solution. Thanks!


Reply With Quote