Being relatively new to ExtJS, only a few weeks in, please excuse the simplicity of my question.
My task involves populating a combo box (SourceSystem) with a list of values based on the selection made in another combo box (DeliveryMethod). Both combos use JSON stores.
To achieve this, I have implemented a listener on combobox 2 as shown below:
listeners:{
'select': function(combo, record,index) {
selectedDelMethod = record.data.codeValue;
var srcSystem = Ext.getCmp('sourceSystemCombo');
srcSystem.reset();
srcSystem.store.reload({
params: {
attrID: 3002,
delvMethod: selectedDelMethod
}
});
}
The above code successfully loads different lists into the srcSystem.store based on selectedDelMethod. However, upon loading the SourceSystem combo box, the default value is not displayed.
fieldLabel: 'Source System',
id: 'sourceSystemCombo',
xtype: 'combo',
mode: 'local',
triggerAction: 'all',
forceSelection: true,
editable: false,
name: 'sourceSystem',
displayField: 'shortDescription',
valueField: 'codeValue',
hiddenName: 'sourceSystem',
store: sourceSystemStore,
listeners: {
'afterrender': function(combo){
var selectedRecord = combo.getStore().getAt(0);
combo.setValue(selectedRecord);
}
}
I am aware that I must be overlooking something in the afterrender listener. Could you kindly guide me on how to set the first value as the default value?