Create a list and populate it from a JSON source using Sencha Touch

I am having problems with what should be simple, but cannot make it work. I tried several examples from different sites and looked at the Sencha Touch API, but no luck. I am trying to just populate a list from an external JSON source. To make this as simple as possible, I just added it to an external file.

Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady : function() {

    Ext.regModel('Contact', {
        fields: ['firstName', 'lastName']
    });

   var store = new Ext.data.Store({
            model: 'Contact',
            sorters: 'firstName',

            getGroupString : function(record) {
                return record.get('firstName')[0];
            },
            proxy: {
                type: 'ajax',
                url : 'test.json',
                reader: {
                    type: 'json'
                }
            }
        });

   var list = new Ext.List({
        fullscreen: true,

        itemTpl : '{firstName} {lastName}',    
        store: store
    });
    list.show();}});

Json file

[
{
    "firstName" : "pelle",
    "lastName": "ollesson"
},
{
    "firstName" : "nisse",
    "lastName": "pellssdfok"
}
]

Is there something that you can see right away is wrong?

Thanks in advance

+3
source share
1 answer

Good, decided. When I removed the sorters and getGroupString, it unexpectedly worked.

+2
source

All Articles