1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    28
    Vote Rating
    0
    Null can only hope to improve

      0  

    Question Json Store: Unable to load data using the supplied configuration.

    Json Store: Unable to load data using the supplied configuration.


    Argh! I'm tearing my hair out with this

    I've dabbled with jquery and ExtJS in the past, so I thought I'd give the EXT Designer a whirl.

    I've got a webservice that returns json as below (copy/pasted from firefox jsonview extension):

    {
    * d: "{"Table":[{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"},{"cur":"PA"}]}"
    }

    My EXT Designer code is:

    MyStore = Ext.extend(Ext.data.JsonStore, {
    constructor: function(cfg) {
    cfg = cfg || {};
    MyStore.superclass.constructor.call(this, Ext.apply({
    storeId: 'MyStore',
    url: 'http://localhost/wcf/timeservice.svc/mylist',
    root: 'Table',
    idProperty: 'cur',
    fields: [
    {
    name: 'cur'
    }
    ]
    }, cfg));
    }
    });
    new MyStore();


    but when I try to do load data in the EXT Designer I get the popup
    "Unable to load data using the supplied configuration.
    Open in Browser: http://localhost/wcf/timeservice.svc/mylist "

    When I click the link I am prompted to download the json file (or its displayed in firefox with jsonview extension)

    Any pointers?

  2. #2
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Arrow Double check it

    Double check it


    "Table" is not the root of your data... "* d" is...

    For Table to be the root, your output should look like this:
    Code:
    {"Table": [{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"},
    {"cur": "PA"},{"cur": "PA"},{"cur": "PA"},{"cur": "PA"}]}
    Your current output is invalid JSON! You should use http://jsonlint.com/ to verify your output formatting!
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    28
    Vote Rating
    0
    Null can only hope to improve

      0  

    Default


    *Face-Palm!*

    hmm... ok, that was a bad copy paste I think - json shown in jsonview firefox plugin doesnt include the escapre chars, where as it does in IE's download file.

    In the mean time, to simplify things I've configuered my webservice to return the following json:
    Code:
    "{"Table":[{"cur":"PA"},{"cur":"PB"}]}"
    which once you paste into jsonlint (removing outer double quotes) shows as Table with 2 rows, 1 property each - thats what I'm after

    Here's my Ext Designer code for the store:
    Code:
    MyStore = Ext.extend(Ext.data.JsonStore, {
        constructor: function(cfg) {
            cfg = cfg || {};
            MyStore.superclass.constructor.call(this, Ext.apply({
                storeId: 'MyStore',
                url: 'http://localhost/wcf/timeservice.svc/mylist',
                autoLoad: true,
                fields: [
                    {
                        name: 'field',
                        mapping: 'cur'
                    }
                ]
            }, cfg));
        }
    });
    new MyStore();
    When I load store in EXT Designer it says there's 47 records (which clearly there isnt). How do I point it at the unique rows - do I need a unique key for the id field or something?
    Last edited by Null; 28 Jun 2011 at 6:49 AM. Reason: update

  4. #4
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Arrow


    I see nothing obviously wrong with your js code... I would look closer at the output of your web-service. Worth noting that the length of the string output of your provided JSON is 37 char's long. Also, why do you encapsulate the final JSON in quotes? Is that how it appears directly from your web-service? If so, remove that.
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  5. #5
    Sencha User
    Join Date
    Jan 2011
    Posts
    28
    Vote Rating
    0
    Null can only hope to improve

      0  

    Default


    Nailed it!

    Using fiddler it shows the webservice is wrapping the json string in double quotes. My webservice is vb.net wcf function that returns a string, the way I got round this is by doing context.write jsonString as opposed to return jsonString at the end of the function.

    I'm sure this isnt the best way, but it proves the logic. I'll have to do some googling and see if I can return the json without the double quotes.

    Thanks for your pointers

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar