PDA

View Full Version : combobox with jsonreader problem



dancaescu
11 Jan 2012, 6:37 PM
Hi,

I have the code listed below. For some reason, i am getting an empty combo box (no values), with blank lines (I have seven results in the db, and i get seven results as blank lines. Where is the mistake?



},{
header:'Brand',
dataIndex:'brand',
width:40,
sortable:true,
align:'right',
editor: new Ext.form.ComboBox({
id: 'brand',
displayField: 'name',
valueField: 'id',
typeAhead: true,
forceSelection: true,
mode: 'remote',
editable: true,
triggerAction: 'all',
allowBlank: false,
emptyText: 'Select brand',
store: new Ext.data.Store({
id:0,
proxy:new Ext.data.HttpProxy({url:'brands/index.php',method:'GET'}),
reader:new Ext.data.JsonReader({
root:'brands',
method:'GET',
id:'id',
fields:[
{name:'id', type:'int'},
{name:'value',type:'string'}
]

})
})

})

},{

dancaescu
11 Jan 2012, 6:38 PM
Thats the reply i get from the http GET:




{"brands":[{"id":"1","name":"Linksys"},{"id":"2","name":"Sipura"},{"id":"3","name":"Grandstream"},{"id":"4","name":"Polycom"},{"id":"5","name":"Cisco"},{"id":"6","name":"Nortel"},{"id":"7","name":"Snom"},{"id":"8","name":"Aastra"},{"id":"9","name":"Yealink"}]}

devnullable
11 Jan 2012, 8:29 PM
You have defined


fields: [
{name:'id', type:'int'},
{name:'value',type:'string'}
]


but your returned JSON have fields 'id' and 'name', not 'id' and 'value'.