I\'m migrating my application from ExtJs 3 to 4 version. I have several comboboxes at my formPanel, and previously I\'ve used hiddenName and all that stuff to submit valueFi
The best way for doing this is that listen to afterrender
event and then set the default value in the callback function.
See this code:
new Ext.form.field.ComboBox({
//This is our default value in the combobox config
defaultValue: 0,
listeners: {
//This event will fire when combobox rendered completely
afterrender: function() {
//So now we are going to set the combobox value here.
//I just simply used my default value in the combobox definition but it's possible to query from combobox store also.
//For example: store.getAt('0').get('id'); according to Brik's answer.
this.setValue(this.defaultValue);
}
}
});