1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    9
    Vote Rating
    0
    wsharp@advresearch.com is on a distinguished road

      0  

    Default Unanswered: Store Not Parsing JSON Data

    Unanswered: Store Not Parsing JSON Data


    I have a Store that gets JSON data from a WCF service. The store is calling the web service and getting data back, but my chart still displays no data, so I'm assuming it's not parsing it correctly.


    **Here is my code:**


    Code:
        // Define Model
        Ext.regModel('chart1model', {
            fields: [
                {name: 'name', type: 'string'},
                {name: 'data', type: 'int'}
            ]
        });
        
        
        var store1 = new Ext.data.Store({
            model: 'chart1model', 
            proxy: {
                type: 'ajax',
                url: 'http://localhost:8523/WebService/GetChartData?chartType=1',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });


    If I take the same data and create the Store myself, the chart displays correctly:




    Code:
        var store1 = new Ext.data.JsonStore({
                fields: ['name', 'data'],
                data: [
                {'name':'Nov-09','data':0},{'name':'Nov-10','data':0},{'name':'Nov-11','data':0},{'name':'Nov-12','data':0},{'name':'Nov-13','data':0},{'name':'Nov-14','data':0},{'name':'Nov-15','data':0},{'name':'Nov-16','data':0},{'name':'Nov-17','data':0},{'name':'Nov-18','data':0},{'name':'Nov-19','data':0},{'name':'Nov-20','data':0},{'name':'Nov-21','data':0},{'name':'Nov-22','data':0},{'name':'Nov-23','data':0},{'name':'Nov-24','data':0},{'name':'Nov-25','data':0},{'name':'Nov-26','data':0},{'name':'Nov-27','data':0},{'name':'Nov-28','data':0},{'name':'Nov-29','data':0},{'name':'Nov-30','data':0}
                ]
            });
    I'm not sure what I'm doing wrong. Any help would be greatly appreciated.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    Any errors? Are you on the same origin (localhost:8523)?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    9
    Vote Rating
    0
    wsharp@advresearch.com is on a distinguished road

      0  

    Default


    Not on the same origin, but a work around is in place.

    To confirm the data I get back I am using jQuery to consume the service, and then viewing the output in the browser. I then take that output I receive from the web service and manually create an Ext.Data.Store. This works flawlessly.

    However if I try to consume the web service in the Ext.Data.Store, such as in my first example above; I can see it in debug call the web service, and the web service returns data, but no data is stored.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    Does your server support CORS? Meaning is it sending the needed headers?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  5. #5
    Sencha User
    Join Date
    Oct 2012
    Posts
    9
    Vote Rating
    0
    wsharp@advresearch.com is on a distinguished road

      0  

    Default


    Yes, it's sending the headers.

    I've just tried using jQuery to consume the wcf service and store the json data returned in a variable. Then assign that variable to the data field in an Ext.data.store, but I'm getting the error "Cannot read property 'length' of undefined "

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    Ok, so it sounds like you don't have a config set properly. What is a sample of the data and your store config?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  7. #7
    Sencha User
    Join Date
    Oct 2012
    Posts
    9
    Vote Rating
    0
    wsharp@advresearch.com is on a distinguished road

      0  

    Default


    Code:
    var store1 = new Ext.data.JsonStore ({
        fields: ["name","data"],
        data: retVal
    });
    Where retVal =

    [{"name":"Nov-12","data":0},{"name":"Nov-13","data":0},{"name":"Nov-14","data":0},{"name":"Nov-15","data":0},{"name":"Nov-16","data":0},{"name":"Nov-17","data":0},{"name":"Nov-18","data":0},{"name":"Nov-19","data":0},{"name":"Nov-20","data":0},{"name":"Nov-21","data":0},{"name":"Nov-22","data":0},{"name":"Nov-23","data":0},{"name":"Nov-24","data":0},{"name":"Nov-25","data":0},{"name":"Nov-26","data":0},{"name":"Nov-27","data":0},{"name":"Nov-28","data":0},{"name":"Nov-29","data":0},{"name":"Nov-30","data":0},{"name":"Dec-01","data":0},{"name":"Dec-02","data":0},{"name":"Dec-03","data":0}]

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    This works for me in ST 1.1.1:

    Code:
    var retVal = [
        {"name" : "Nov-12", "data" : 0},
        {"name" : "Nov-13", "data" : 0},
        {"name" : "Nov-14", "data" : 0},
        {"name" : "Nov-15", "data" : 0},
        {"name" : "Nov-16", "data" : 0},
        {"name" : "Nov-17", "data" : 0},
        {"name" : "Nov-18", "data" : 0},
        {"name" : "Nov-19", "data" : 0},
        {"name" : "Nov-20", "data" : 0},
        {"name" : "Nov-21", "data" : 0},
        {"name" : "Nov-22", "data" : 0},
        {"name" : "Nov-23", "data" : 0},
        {"name" : "Nov-24", "data" : 0},
        {"name" : "Nov-25", "data" : 0},
        {"name" : "Nov-26", "data" : 0},
        {"name" : "Nov-27", "data" : 0},
        {"name" : "Nov-28", "data" : 0},
        {"name" : "Nov-29", "data" : 0},
        {"name" : "Nov-30", "data" : 0},
        {"name" : "Dec-01", "data" : 0},
        {"name" : "Dec-02", "data" : 0},
        {"name" : "Dec-03", "data" : 0}
    ];
    
    var store1 = new Ext.data.JsonStore({
        fields : ['name', 'data'],
        data   : retVal
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  9. #9
    Sencha User
    Join Date
    Oct 2012
    Posts
    9
    Vote Rating
    0
    wsharp@advresearch.com is on a distinguished road

      0  

    Default


    Alright, figured it out. It was returning a string, but Ext.data.strore was expecting an JSON array. If I parse the string to JSON it works fine.

    Code:
    var retVal = $.parseJSON(retVal);
    
    var store1 = new Ext.data.JsonStroe({
        fields : ['name','data'],
        data : retVal
    });

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi