1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    54
    Vote Rating
    0
    Rui Marinho is on a distinguished road

      0  

    Default Answered: Problem loading odata store

    Answered: Problem loading odata store


    I m trying to parse some odata json feed to my store, i don't get any error, but it also doesn't load nothing, the data array doesn't have any items: Here's my code

    Code:
    Ext.define('Something.model.Concelho', {    extend: 'Ext.data.Model',
        config: {
    
    
            fields: [
    
    
            { name: 'ConcelhoID', type: 'int' },
    
    
            { name: 'Concelho', type: 'string' },
            { name: 'Concelho', type: 'int' }
            ]
        }
    });
    
    
    Ext.define('Something.store.Concelhos', {
        extend: 'Ext.data.Store',
        requires: ['Ext.data.proxy.JsonP'],
        config: {
                 model: 'Something.model.Concelho',
                proxy: {
                    type: 'jsonp',
                    url: 'http://192.168.1.201/service.svc/Concelhos?$format=json',
                    enablePagingParams: false,
                     noCache: false,
                     root: 'd'
                        
                }
            }
    });
    
        var store = Ext.create('Something.store.Concelhos');
            Ext.create('Something.view.ConcelhosList', {
                store: store
            });
    
    
            store.load();
    JSON:
    Code:
    {
        "d": [
            {
                "__metadata": {
                    "uri": "http://192.168.1.201/iWorkAPI/iWorkService.svc/Concelhos(1)",
                    "type": "iWorkDWModel.Concelhos"
                },
                "ConcelhoID": 1,
                "Concelho": "\\u00c1gueda",
                "DistritoID": 1
            },
            {
                "__metadata": {
                    "uri": "http://192.168.1.201/iWorkAPI/iWorkService.svc/Concelhos(2)",
                    "type": "iWorkDWModel.Concelhos"
                },
                "ConcelhoID": 2,
                "Concelho": "Albergaria-a-Velha",
                "DistritoID": 1
            },
            {
                "__metadata": {
                    "uri": "http://192.168.1.201/iWorkAPI/iWorkService.svc/Concelhos(3)",
                    "type": "iWorkDWModel.Concelhos"
                },
                "ConcelhoID": 3,
                "Concelho": "Anadia",
                "DistritoID": 1
            }
        ]
    }
    Last edited by mitchellsimoens; 27 Mar 2012 at 5:42 AM. Reason: formatted JSON with jsonpint.com

  2. Try this:

    Code:
    Ext.define('Something.model.Concelho', {
        extend: 'Ext.data.Model',
    
        config: {
            idProperty : 'ConcelhoID',
            fields: [
                { name: 'ConcelhoID', type: 'int' },
                { name: 'Concelho', type: 'string' },
                { name: 'Concelho', type: 'int' }
            ]
        }
    });
    
    
    Ext.define('Something.store.Concelhos', {
        extend: 'Ext.data.Store',
    
        requires: ['Ext.data.proxy.JsonP'],
        
        config: {
            model: 'Something.model.Concelho',
            proxy: {
                type: 'jsonp',
                url: 'http://192.168.1.201/service.svc/Concelhos?$format=json',
                enablePagingParams: false,
                noCache: false,
                reader : {
                    type : 'json',
                    rootProperty: 'd'
                }
            }
        }
    });
    The things I changed is renamed 'root' to 'rootProperty' and moved 'rootProperty' into the reader. Also added idProperty to the Model, it's a good idea to have that.

    Let me know if that works for you.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,735
    Answers
    3364
    Vote Rating
    756
    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


    Try this:

    Code:
    Ext.define('Something.model.Concelho', {
        extend: 'Ext.data.Model',
    
        config: {
            idProperty : 'ConcelhoID',
            fields: [
                { name: 'ConcelhoID', type: 'int' },
                { name: 'Concelho', type: 'string' },
                { name: 'Concelho', type: 'int' }
            ]
        }
    });
    
    
    Ext.define('Something.store.Concelhos', {
        extend: 'Ext.data.Store',
    
        requires: ['Ext.data.proxy.JsonP'],
        
        config: {
            model: 'Something.model.Concelho',
            proxy: {
                type: 'jsonp',
                url: 'http://192.168.1.201/service.svc/Concelhos?$format=json',
                enablePagingParams: false,
                noCache: false,
                reader : {
                    type : 'json',
                    rootProperty: 'd'
                }
            }
        }
    });
    The things I changed is renamed 'root' to 'rootProperty' and moved 'rootProperty' into the reader. Also added idProperty to the Model, it's a good idea to have that.

    Let me know if that works for you.
    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.

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    54
    Vote Rating
    0
    Rui Marinho is on a distinguished road

      0  

    Default


    I also tried changing to but it still doesn't work.

    rootProperty: 'd'

    also if i do Ext.StoreMgr.all in my console, i can see that i have 2 stores of the same type.
    the first one is the one binded to my list, it shows 0 items, but the second one is the same type, with a diffrent id, and i see some data there

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,735
    Answers
    3364
    Vote Rating
    756
    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


    Did you move it to the reader config? I used your JSON and the store/model I posted and it works (changed URL of course).

    Is your response wrapped in the callback function?
    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.

  6. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    54
    Vote Rating
    0
    Rui Marinho is on a distinguished road

      0  

    Default


    Spot on! Thanks, movind that to the reader solved the issue.

    i m still a little proble, the property Concelho isn't showing up.. it shows me NaN ?? not a numeber? is a string field , the ConcelhoID is a int and it's getting parsed well to my model...

    any ideas?

  7. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    54
    Vote Rating
    0
    Rui Marinho is on a distinguished road

      0  

    Default


    FOrget it.. i'm lamme!!!!! copy pasted sucks :P

  8. #7
    Sencha User
    Join Date
    Mar 2010
    Posts
    55
    Vote Rating
    0
    necco is on a distinguished road

      0  

    Default


    hi
    how to wrap the response in the callback function?
    I do not know how to load the store into the application launch function. How to initialize the main view with the store loaded?

    thanks

Thread Participants: 2

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