如何在Ext Js中自动选择(显示)组合框的第一个值?

ilh*_*han 16 combobox extjs extjs3

这是我的组合框

{
    xtype: 'combo', 
    fieldLabel: LANG.LOGIN_LANG,
    id : 'lang', 
    store: [
        ['tr','Türkçe'],
        ['ru','???????'],
        ['en','English']
    ],
    mode: 'local',
    triggerAction: 'all',
    selectOnFocus:true
},
Run Code Online (Sandbox Code Playgroud)

M-S*_*M-S 31

通常,当我想选择商店的第一个值时,我使用以下方法:

xtype: 'combo', 
fieldLabel: 'prov',
id : 'lang', 
store:[['tr','Türkçe'],['ru','???????'],['en','English']],
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
listeners: {
    afterrender: function(combo) {
        var recordSelected = combo.getStore().getAt(0);                     
        combo.setValue(recordSelected.get('field1'));
    }
}
Run Code Online (Sandbox Code Playgroud)


Mch*_*chl 21

{
  xtype: 'combo', 
  fieldLabel: LANG.LOGIN_LANG,
  id : 'lang', 
  store:[['tr','Türkçe'],['ru','???????'],['en','English']],
  mode: 'local',
  triggerAction: 'all',
  value: 'tr',
  selectOnFocus:true
},
Run Code Online (Sandbox Code Playgroud)

对于远程组合框,您需要插入商店的load事件以选择加载商店后的值.


小智 11

您可以像这样使用value属性:

value : 'tr'

那么它默认会显示第一个值.