1. #1
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    24
    Vote Rating
    1
    Beth_B is on a distinguished road

      0  

    Default JSON Help

    JSON Help


    I am trying to pull json data. The store is created; the data is pulled; however, the data is not in the store. The proxy returns {"Bars":[{"Name":"Sunday","Data":10},{"Name":"Monday","Data":20},{"Name":"Tuesday","Data":30},{"Name":"Wednesday","Data":40},{"Name":"Thursday","Data":50}]}. I have the following js:

    Ext.define('ModelX', {
    extend:
    'Ext.data.Model',
    fields: [
    { name:
    'Name', mapping: 'Name', type: 'string' },
    { name:
    'Data', mapping: 'Data', type: 'int' }
    ]
    });


    var myStore = Ext.create('Ext.data.Store', {
    model: 'ModelX',
    proxy: {
    type: 'ajax',
    url: 'Home/TestData',
    reader: {
    type: 'json',
    root: 'Bars'
    }
    },
    listeners: {
     
    exception: { fn: function (el, response, operation, eOpts) {
    var error = operation.getError();
    console.log("ERROR: " + error);
    }
    }//end exception
    },
    autoLoad: true
    });

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    How are you ascertaining that there's no data in the store? Like this perhaps?

    Code:
    listeners: {
        load: function(store) {
            console.log(store.getCount());
        }
    }

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    24
    Vote Rating
    1
    Beth_B is on a distinguished road

      0  

    Default Thanks for help

    Thanks for help


    Thank you! Apparently I was checking the data store values before they were populated. I thought I had a blocking action but it looks like I did not.

Thread Participants: 1