How to use Ext5 combobox with data bindings

Erik Theoboldt picture Erik Theoboldt · Aug 12, 2014 · Viewed 7.5k times · Source

I want to use a combobox which receives the preselected value from a data binding and also the possible options from a data binding of the same store. The panel items configuration looks like this:

{
    xtype: 'combobox',
    name: 'language_default',
    fieldLabel: 'Default Language',
    multiSelect: false,
    displayField: 'title',
    valueField: 'language_id',
    queryMode: 'local',
    bind: {
        value: '{database.language_default}',
        store: '{database.languages}'
    }
}

If I use this configuration, the store of the combobox is invalid and unuseable.

Is it possible to bind the selected option and also the available options of a combobox?

Answer

Sven Tore picture Sven Tore · Aug 14, 2014

Upgrade to ExtJs 5.0.1 and you can use selection binding

{
    xtype: 'combobox',
    name: 'language_default',
    fieldLabel: 'Default Language',
    multiSelect: false,
    displayField: 'title',
    valueField: 'language_id',
    queryMode: 'local',
    bind: {
        value: '{database.language_id}',
        selection: '{database.language_default}',
        store: '{database.languages}'
    }
}