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.
Asked
Active
Viewed 3,797 times
0
-
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 Answers
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
-
Please post your code. So that people will be able to figure out problem in you code. – Harshal Mar 13 '16 at 15:17
0
Try to set default value after load store.
YourComboBox.setValue('default value');

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