Contains search in combobox
Make your combobox perform contains search
HTML
<link rel="stylesheet" href="http://extjs.cachefly.net/ext-4.0.2a/resources/css/ext-all-gray.css">
JavaScript
// The data store containing the list of cars
var cars = Ext.create('Ext.data.Store', {
fields: ['key', 'name'],
data: [{
"key": "Benz",
"name": "Mercedes-Benz"
}, {
"key": "Audi",
"name": "Audi"
}, {
"key": "Ferrari",
"name": "Ferrari"
}, {
"key": "Prius",
"name": "Prius"
}, {
"key": "Lamborghini",
"name": "Lamborghini"
}, {
"key": "BMW",
"name": "BMW"
}
//...
]
});
// Create the combo box, attached to the cars data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose Car',
store: cars,
queryMode: 'local',
displayField: 'name',
valueField: 'key',
renderTo: Ext.getBody(),
listeners: {
beforequery: function (record) {
record.query = new RegExp(record.query, 'i');
record.forceAll = true;
}
}
});
// Create the text box, attached to the cars data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose Car',
store: cars,
queryMode: 'local',
displayField: 'name',
valueField: 'key',
renderTo: Ext.getBody(),
hideTrigger: true, //this will convert the combobox into a textbox
listeners: {
beforequery: function (record) {
record.query = new RegExp(record.query, 'i');
record.forceAll = true;
}
}
});