PDA

View Full Version : JsonReader non associative



pex
24 Apr 2007, 6:23 AM
I have a non associative array that is generated on the server and encoded into json, it looks like this:

{"total":60,"data":[{"BO":"You best believe","FAN":"Fantasy","Noo":"Number" ....

etc.etc.

Now I want to use this data in a combobox, so for the reader I use:



reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'total'
}, [
{name: 0, mapping: 0},
{name: 1, mapping: 1}
])


The mapping doesn't seem to work though, any ideas on how I can access the first and second index from the json array?

Animal
24 Apr 2007, 7:14 AM
Should work. I'd give the fields meaningful names though:



reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'total'
}, [
{name: "code", mapping: 0},
{name: "description", mapping: 1}
])


That should populate your Store correctly. Have you checked your Store object in Firebug. It's easy to look into it and see its Records.

What does your combobox pull out of the Store?