The js is not minified so it is readable. See combos.js.
Data Sources
The combo box can use any type of Ext.data.Store as it's data source.
This means your data can be XML, JSON, arrays or any other supported format. It can be loaded using Ajax, script tags or be local.
This combo uses local data from a JS array:
// simple array store
var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : exampleData
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
applyTo: 'local-states'
});
The combo below uses the same data, but also illustrates how to use an optional custom template to create custom UI renditions for list items. In this case, each item has a popup QuickTip which displays the state's nickname when hovered over.
// simple array store
var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state', 'nick'],
data : exampleData
});
var comboWithTooltip = new Ext.form.ComboBox({
tpl: '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>',
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
applyTo: 'local-states-with-qtip'
});
Unobtrusive
The combo box can very easily be used to convert existing select elements into auto-completing, filtering combos.
Originally looked like:
var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'state',
width:135,
forceSelection:true
});
Grid Editor
Click here to see the combo as a grid editor.
Templates and Ajax
Click here for a more advanced example.