PDA

View Full Version : ComboBox with Store and JsonReader



rapisthesolution
27 Jul 2009, 8:10 AM
Hi,

I have some problems with reading my json generated data into a combobox.
It doesn't show the data :-(


My DataStore:


jobDataStore = new Ext.data.Store({
id: 'jobDataStore',
proxy: new Ext.data.HttpProxy({
url: 'services.aspx',
method: 'POST'
}),
baseParams: { task: "GETJOBS" },
reader: new Ext.data.JsonReader({
root: 'results',
//totalProperty: 'total',
id: 'No'
}, [
{ name: 'No', type: 'string' },
{ name: 'Description', type: 'string' }
]),
sortInfo: { field: 'No', direction: "ASC" }
});

jobDataStore.load();


The column inside a editor grid:


...

header: 'Job No.',
dataIndex: 'no',
width: 150,
editor: new Ext.form.ComboBox({
store: jobDataStore,
displayField: 'Description',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
selectOnFocus: true
})
...


I get the following json from my service:


{
results: [
{
"No":"10023",
"Description":"BLABLA"
},
{
"No":"55405",
"Description":"ZOMFG"
}
]
}

Can someone explain me where my mistake is?

bocockli
28 Jul 2009, 12:11 AM
It looks ok. Start debugging at the beginning.


In Firebug what do you get from the HTTP GET response back from the server? Are you seeing the JSON data come the server that you expect?
Using console.log(), log the store load event and make sure the jobDataStore has data in it.
Is it a rendering timing issue? Try calling jobDataStore.load(); from the render event of the ComboBox rather than after you create the store.Regards, Len

rapisthesolution
28 Jul 2009, 12:36 AM
Thx for your reply. I already solved it in the morning.

There was a problem with my webservice.

Ext rules :-)