-
17 Dec 2011 6:35 AM #1
nestedlist json data not showing up
nestedlist json data not showing up
Hi,
I'm trying to get the simple nested list demo working with PR3. The data is not showing up in the nested list. I believe I'm doing everything right but I am new to sencha and JS. Any help would be greatly appreciated.
Here's the main app:
Ext.setup({
tabletStartupScreen: 'sources/icons/tablet_startup.png',
phoneStartupScreen: 'sources/icons/phone_startup.png',
icon: 'sources/icons/icon.png',
glossOnIcon: false,
onReady: function() {
Ext.define('ListItem', {
extends: 'Ext.data.Model',
fields: [{name: 'text', type: 'string'}]
});
var store = new Ext.data.TreeStore({
model: 'ListItem',
proxy: {
type: 'ajax',
url: 'groceries.json',
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true
});
new Ext.NestedList({
fullscreen: true,
title: 'Groceries',
displayField: 'text',
store: store
});
}
});
Here's the groceries.json file in the same folder as the app.
{
"text": "Groceries",
"items": [
{
"text": "Drinks",
"items": [
{
"text": "Water",
"items": [
{
"text": "Sparkling",
"leaf": true
},
{
"text": "Still",
"leaf": true
}
]
},
{
"text": "Coffee",
"leaf": true
},
{
"text": "Espresso",
"leaf": true
},
{
"text": "Redbull",
"leaf": true
},
{
"text": "Coke",
"leaf": true
},
{
"text": "Diet Coke",
"leaf": true
}
]
},
{
"text": "Fruit",
"items": [
{
"text": "Bananas",
"leaf": true
},
{
"text": "Lemon",
"leaf": true
}
]
},
{
"text": "Snacks",
"items": [
{
"text": "Nuts",
"leaf": true
},
{
"text": "Pretzels",
"leaf": true
},
{
"text": "Wasabi Peas",
"leaf": true
}
]
},
{
"text": "Empty Category",
"items": []
}
]
}
-
17 Dec 2011 7:40 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
Please wrap code in the code tags so it's easy to ready. Here is code that is working for me:
The problem I spotted as that 'extends' in your model needs to be 'extend'Code:Ext.define('ListItem', { extend : 'Ext.data.Model', fields : [ { name : 'text', type : 'string' } ] }); Ext.setup({ onReady: function() { var store = Ext.create('Ext.data.TreeStore', { model : 'ListItem', autoLoad : true, proxy : { type : 'ajax', url : 'groceries.json', reader : { type : 'json', root : 'items' } } }); Ext.create('Ext.NestedList', { fullscreen : true, title : 'Groceries', displayField : 'text', store : store }); } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote