PDA

View Full Version : Loading a comboBox from a JSON store



cwolves
20 Oct 2010, 9:58 AM
Hi All,

I'm just trying to get a comboBox to load from a JSON store, but can't seem to get the comboBox to populate. Any help would be appreciated :)


var store = new Ext.data.JsonStore({
reader : new Ext.data.JsonReader()
});

store.loadData({
metaData : {
fields : [
{name : 'name'},
{value : 'value'}
],
root : 'rows'
},
'rows' : [
{ value : 1, name : 'Bill'},
{ value : 2, name : 'Ben'}
]
});

var foo = new Ext.form.ComboBox({
renderTo : document.body,
store : store,
valueField : 'value',
displayField : 'name',
lazyRender : true
});

plalx
20 Oct 2010, 10:07 AM
Did not checked your store code, but if your records are getting loaded properly in the store... try adding the mode: 'local' config option on the combobox. And remove the lazyRender config option since you are rendering it directly using renderTo.

cwolves
20 Oct 2010, 10:11 AM
THANK YOU! THANK YOU, THANK YOU!