PDA

View Full Version : Can't reach second level of NestedList with JSON data



davemckenna01
10 Mar 2011, 1:53 PM
Hello! I'm trying to put some JSON data in a NestedList, but I'm not able to drill down past the 1st level.

I have the following JSON:


{
"dishes": [
{
"text": "turkey salad",
"leaf": false,
"ingredients": [
{
"text": "turkey",
"leaf": true
},
{
"text": "lettuce",
"leaf": true
}
]
},
{
"text": "salmon souflee",
"leaf": true,
"ingredients": []
}
]
}

and I'm putting it in to a NestedList via a TreeStore:


NestedListDemo.meal_store = new Ext.data.TreeStore({
model: 'Dish',
proxy: {
type: 'ajax',
url: '/api/lists/dish/vegetarian-mousaka/',
reader: {
type: 'tree',
root: 'dishes'
}
}
});

So the top level shows "turkey salad" and "salmon souflee", but selecting "turkey salad" just slides in a panel with those same two top level items, and that goes on infinitely.

If I rename "dishes" to "items", and then rename "ingredients" to "items" as well, all is good. But is there a way where I don't have to do that? Makes for kind of un-semantic json.

Thanks in advance,

Dave