17

これは私のコンボボックスです

{
    xtype: 'combo', 
    fieldLabel: LANG.LOGIN_LANG,
    id : 'lang', 
    store: [
        ['tr','Türkçe'],
        ['ru','Русский'],
        ['en','English']
    ],
    mode: 'local',
    triggerAction: 'all',
    selectOnFocus:true
},
4

5 に答える 5

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'));
    }
}
于 2011-07-15T15:21:16.550 に答える
23
{
  xtype: 'combo', 
  fieldLabel: LANG.LOGIN_LANG,
  id : 'lang', 
  store:[['tr','Türkçe'],['ru','Русский'],['en','English']],
  mode: 'local',
  triggerAction: 'all',
  value: 'tr',
  selectOnFocus:true
},

loadリモートコンボボックスの場合、ストアがロードされた後に値を選択するためにストアのイベントにプラグインする必要があります。

于 2011-07-15T09:36:27.933 に答える
12

次のようにvalueプロパティを使用できます。

value : 'tr'

次に、デフォルトで最初の値が表示されます。

于 2011-07-15T09:26:12.993 に答える
0

このコードを使用して、IDの後の任意のストア要素をデフォルトのコンボボックス値に割り当てることができます。

{ 
  xtype: 'combobox',
  forceSelection: true,
  allowBlank: true,
  typeAhead: true,
  queryMode: 'local',
  colspan: 3,
  id: 'filter_column_c',
  style: {'margin': '5px 15px 15px 30px'},
  fieldLabel: 'Column',
  valueField: 'column',
  displayField: 'name',
  store: nomStores["storeCombo"],
  value: nomStores["storeCombo"].getById(1),
},
于 2015-12-08T09:57:53.237 に答える
-1

別の方法として、ローカルに保存されたストアを表示する必要がありました。これは、afterRenderメソッドをリッスンするだけの問題でした。

listeners: {
    afterRender: function() {
        this.select(01);
    }
}

01この場合、ストア内の要素のid(valueField)です。

areasCenters: {
        data: [{
                id: 01,
                name: 'Todas'
            },
            {
                id: 02,
                name: 'Elegir...'
            }
        ],
        autoLoad: true
}
于 2018-05-29T09:44:04.440 に答える