1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    Answers
    1
    dboy221 is on a distinguished road

      0  

    Default Answered: JSON Results not loading into List

    Answered: JSON Results not loading into List


    I have created a WCF service an attempt to call it. I am able to hit the service and get the JSON formatted results. However, when trying to populate a list with the results I do not see the results displayed. I have added logging on the load event for the store to see the number of records returned and I get an undefined for records.length. I have post the code for both the store/model and the view. Thanks in advance to all that help. (S/N, i'm using 1.1 as i'm learning Sencha from an ebook purchased an no relevant literature exist for v2.0)

    /*Model/Store Definition*/
    Code:
    Ext.regModel('CTS.model.Resources', {
        fields: [
        { name: 'ID', type: 'int' }
        ,{ name: 'Name', type: 'string' }
        , { name: 'Type', type: 'string' }
        ]
    });
    
    
    Ext.regStore('CTS.store.Resources', {
        model: 'CTS.model.Resources',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            method: 'GET',
            url: 'http://localhost:50196/WebServices/WebServiceResources.svc/getresources',
            reader: { type: 'json' }
        }
        ,
        listeners: {
            load: function (records) {
                console.log('Loading...' + records.length + ' records');
            }
        }
    });
    /*View Definition*/
    Code:
    CTF.view.Resources = Ext.extend(Ext.Panel, {
        id: 'resources',
        fullscreen: true,
        initComponent: function () {
            Ext.apply(this, {
                dockedItems: [],
                items: [{
                    id: 'lstResources',
                    xtype: 'list',
                    store: 'CTS.store.Resources',
                    itemTpl: '{Name}'
                    
                }]
            });



    CTF.view.Resources.superclass.initComponent.apply(this, arguments);


    }
    });


    Ext.reg('resources', CTF.view.Resources);

  2. I did not specify the root for the JSON formatted text in the reader object for the Store

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    Answers
    1
    dboy221 is on a distinguished road

      0  

    Default Found the Issue

    Found the Issue


    I did not specify the root for the JSON formatted text in the reader object for the Store

Tags for this Thread