Combo Boxes

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 its data source. This means your data can be XML, JSON, arrays or any other supported format. It can be loaded using Ajax, via script tags or locally. 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'
});

The combo box can also use plain array data directly as its data source, wrapping the array internally with a SimpleStore as needed. You can pass a 1-dimensional or multi-dimensional array as the store config:

var comboFromArray = new Ext.form.ComboBox({
    store: exampleData, //direct array data
    typeAhead: true,
    triggerAction: 'all',
    emptyText:'Select a state...',
    selectOnFocus:true,
    applyTo: 'array-states'
});

Unobtrusive
The combo box can very easily be used to convert existing select elements into auto-completing, filtering combos.

Transformed select:

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.