1. #1
    Sencha User
    Join Date
    Nov 2011
    Location
    Tehran
    Posts
    10
    Vote Rating
    0
    h_ghare is on a distinguished road

      0  

    Default Answered: List with proxy

    Answered: List with proxy


    Hi everybody
    I am developing a simple Sencha Touch 2 sample with MVC structure.
    I want a list view that load a json file and show it. I have listed my code but it doesnt show anything.
    Store :
    Code:
    Ext.define('Phonebook.store.Contacts', {
        extend : 'Ext.data.Store',
        model    : 'Phonebook.model.Contact',
        sorters  : 'lastName',
        autoLoad : true,
        proxy: {
            type: 'ajax',
            url : 'contacts.json',
            reader : {
                type            : 'json',
                root            : 'contacts',
                successProperty : 'success',
                totalProperty   : 'total'
            }
        },
    });
    Model :
    Code:
    Ext.define('Phonebook.model.Contact', {
        extend : 'Ext.data.Model',
        fields : [
            { name : 'id',      type : 'int' },
            { name : 'firstName',    type : 'string' },
            { name : 'lastName',    type : 'string' },
            { name : 'email',   type : 'string' },
            { name : 'tel', type : 'string' }
        ],
    });
    JSON file :
    Code:
    {
        "success"    : true,
        "total"      : 2,
        "contacts"   : [
            {
                "id"        : 1,
                "firstName" : "john",
                "lastName"  : "nash",
                "email"     : "j_nash@yahoo.com",
                "tel"       : "09124624557"
            },
            {
                "id"        : 2,
                "firstName" : "tom",
                "lastName"  : "diaz",
                "email"     : "t_diaz@yahoo.com",
                "tel"       : "09124624667"
            }
        ]
    }

  2. Quote Originally Posted by h_ghare View Post
    thanks mitchellsimoens,

    I am running on local, not on web server, do you think it is the problem cause???
    Very much so

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3156
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Using your code, the store is being populated for me.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Location
    Tehran
    Posts
    10
    Vote Rating
    0
    h_ghare is on a distinguished road

      0  

    Default


    thanks mitchellsimoens,

    I am running on local, not on web server, do you think it is the problem cause???

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3156
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Quote Originally Posted by h_ghare View Post
    thanks mitchellsimoens,

    I am running on local, not on web server, do you think it is the problem cause???
    Very much so
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Nov 2011
    Location
    Tehran
    Posts
    10
    Vote Rating
    0
    h_ghare is on a distinguished road

      0  

    Default


    mitchellsimoens, it seems that you are a hero in sencha forum.

    thanks very much