Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Vote Rating
    0
    gorje001 is on a distinguished road

      0  

    Default 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": []
    }
    ]
    }

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,602
    Vote Rating
    1138
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    Please wrap code in the code tags so it's easy to ready. Here is code that is working for me:

    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
            });
    
        }
    });
    The problem I spotted as that 'extends' in your model needs to be 'extend'
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1