Java ExtJs 3组合框设置默认值

Java ExtJs 3组合框设置默认值,java,javascript,extjs,Java,Javascript,Extjs,我是ExtJS新手。。几周前,所以如果这似乎是一个琐碎的问题,请原谅我 我必须根据在另一个组合框(DeliveryMethod)中选择的值加载组合框(SourceSystem)中的值列表。我对这两个组合都使用JSON存储 因此,我在组合框2中添加了一个侦听器作为 listeners:{ 'select': function(combo, record,index) { selectedDelMethod = record.data.codeValue; var

我是ExtJS新手。。几周前,所以如果这似乎是一个琐碎的问题,请原谅我

我必须根据在另一个组合框(DeliveryMethod)中选择的值加载组合框(SourceSystem)中的值列表。我对这两个组合都使用JSON存储

因此,我在组合框2中添加了一个侦听器作为

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

        }
      });        
   }
在这里,srcSystem.store根据selectedDelMethod加载不同的列表。 这很好用。但当加载SourceSystem combox id时,会填充它,但默认值不会显示任何内容

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);        
  }
}
我确信我在afterrender侦听器中遗漏了一些内容。请告诉我如何将第一个值设置为默认值

尝试使用
此.firevent('select',combo,selectedRecord)代替了

combo.setValue(selectedRecord)

我发现combo.getStore().getAt(0)返回null。在尝试了两种方法之后,我设法解决了这个问题。我没有在combobox上放置一个事件,而是更新了store的重载以设置combo中的第一个值。这是你的电话号码

var srcSystem = Ext.getCmp('sourceSystemCombo');
srcSystem.reset();
srcSystem.store.reload({ 
    params: {
        attrID:     3002,
        delvMethod: selectedDelMethod
    },
    scope : this,
    callback : function(records, operation, success){
        srcSystem.setValue(srcSystem.store.getAt(0).get('codeValue'));
    }
});  
combobox上的设置值必须是store上的回调函数,因为store的加载是一个异步过程。瞧

combo.getStore().getAt(0)
将返回数据记录,而
combo.setValue()
接受字符串值引用:尝试从记录中获取值,例如record.data.value