(Sorry for hijaaking but hopefully this will save others some time)
Note that the solution perscribed above appears to only work for local data stores. If you are retrieving from a database, the store will not be loaded until after a selection is made. Therefore no data will be available to set as default. There are a number of workarounds but, IMHO, the most straight-forward seems to be from Brian.Moeskau...(http://extjs.com/forum/showthread.ph...fault+value%3A).
I've added a slight modification. Since I am returning the data with the default record on top, I always populate the combobox with the first record (ex. combo.setValue(store.getAt(0).get('field to display')); ):
PHP Code:
Ext.onReady(function(){
var docStore = new Ext.data.JsonStore({
root: "FacilityDoctors",
fields: ['doctor_id', 'doctor_name'],
url: '../modules/form/getFormElements.php?action=getDoctorCombo'
});
docCombo = new Ext.form.ComboBox({
id:'FacilityDoctors',
store: docStore,
displayField:'doctor_name',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText:'Select Doctor...',
selectOnFocus:true,
valueField:'doctor_id'
})
docCombo.applyTo('doctor_id')
docStore.on('load', function(){
docCombo.setValue(docStore.getAt(0).get('doctor_name')); // always default to first record
docCombo.mode = 'local'; // load once and cache
}, this, {single:true}); // single to make sure this is only done on initial load
docStore.load();
});