2011-07-15 20 views
15

Bu Çok gibi değer özelliği kullanabilirsiniz benim comboboxExt Js'de combobox'ın ilk değeri nasıl seçilir (gösterilsin)?

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

, combobox oluşturmadan önce depolanmış mı yoksa daha sonra depolanmış mı? verilen örnekte satish kumar'ın cevabı sizin çözümünüzdür ... – Zango

cevap

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 
}, 

. Bir mağazanın ilk değeri seçmek istediğinizde

11

geçerli:

value : 'tr'

o zaman varsayılan olarak ilk değeri görüntüler. Eğer mağaza yüklendikten sonra değerini seçmek için mağazanın load olay takmam gereken uzak comboboxes için

+0

Sadece, combobox render edilmeden önce mağaza zaten yüklenmişse. –

28

Genellikle, bu yöntemleri kullanın:

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')); 
    } 
} 
0

Varsayılan combobox değere onun id sonra herhangi mağaza öğesi atama bu kodu kullanabilirsiniz.

{ 
    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), 
}, 
İlgili konular