PDA

View Full Version : loadData into a combo and select



sofway
1 Sep 2010, 3:38 PM
Hi,
i need to load one record into a combo and select it automatically.



var combo = new Ext.form.ComboBox({
id: 'combo',
store: new Ext.data.JsonStore({
url: '/some/url/',
root: 'records',
idProperty: 'id_client',
fields: ['id_client', 'name']
})

});

// Load a record
combo.getStore().loadData({
records: [{"id_client": 2, "name": "somebody"}]
});

// Select it
combo.select(0);



:( it doesnt work
Help me please

polimux
3 Sep 2010, 6:03 AM
You need to set valueField and displayField to tell the combobox what to show.
Then you can select data by calling "combo.setValue(1)".