0

I m trying to set a default value of combo box which is using store. I have tried value, defaultValue and have tried afterrender but nothing seem to work. Did anyone come across with the same problem? Any help would be appreciated.

ashhad
  • 163
  • 1
  • 7
  • 18
  • I don't know why my question was downgraded by a user here. I have put all the information. Well none of the solution worked for me. – ashhad Mar 08 '16 at 14:32
  • Possible duplicate of [Extjs 4 combobox default value](https://stackoverflow.com/questions/5965416/extjs-4-combobox-default-value) – Vadzim Apr 24 '18 at 10:31

2 Answers2

4
// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
    ]
});


Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    value: 'AL', // the value should be an existing  store's valueField
    renderTo: Ext.getBody()
});
Kld
  • 6,970
  • 3
  • 37
  • 50
0

Try to set default value after load store.

YourComboBox.setValue('default value');

https://fiddle.sencha.com/#fiddle/16q4

Yasuyuki Uno
  • 2,417
  • 3
  • 18
  • 22