View Full Version : How to autoselect the first element in a combobox?

16 Feb 2010, 6:03 AM

I am creating a ComboBox and after render would like to show default value, which token from my store (assume the first value of my store). Specifying autoSelect parameter the problem is not solved:

// obtain the values of the data series locomotives from an external source

var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'asp/json/json_marshrut.asp?param=serlok'}),
reader: new Ext.data.JsonReader({
totalProperty: '', root:'' }, [{name: 'SERLOK'},{name: 'SERNAME'}])
autoload: true }),

// combobox element, with autoselect from data.store

SerLok = new Ext.form.ComboBox({
store: store,
autoSelect: true,
allowBlank: false,
typeAhead: true,
mode: 'remote',
valueField: 'SERLOK'

Please help, i can not find the correct variant of the solution. Thanks!

16 Feb 2010, 6:06 AM
Load it statically at page generation time. Have the page generation script include "asp/json/json_marshrut.asp?param=serlok" into an object, and then preload the Store, and just call setValue on the Combo

16 Feb 2010, 6:11 AM
Thank you for your prompt response, Animal! I think this will solve my problem.