1. #1
    Ext User
    Join Date
    Jul 2010
    Posts
    32
    Vote Rating
    0
    fgeorge is on a distinguished road

      0  

    Default Models, localstorage, store and remote JSON

    Models, localstorage, store and remote JSON


    Hello,

    I have a remote JSON feed that i would like to pass through a model and save in html 5 localstorage using a store. i found some sample code for this in the API Docs.

    Code:
    // Set up a model to use in our Store
    Ext.regModel('User', {
        fields: [
            {name: 'firstName', type: 'string'},
            {name: 'lastName',  type: 'string'},
            {name: 'age',       type: 'int'},
            {name: 'eyeColor',  type: 'string'}
        ]
    });
    
    var myStore = new Ext.data.Store({
        model: 'User',
        proxy: {
            type: 'ajax',
            url : '/users.json',
            reader: {
                type: 'json',
                root: 'users'
            }
        },
        autoLoad: true
    });
    Now the example here uses a local JSON URL..My JSON feed is remote..Will the above code work if i change the url to http://xyz.com/sample.json ?

    Or does JSONP come into play somewhere..If so how?

    Thanks

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


    The AjaxProxy will not allow cross-domain calls. You will have to use JSONP or ScriptTagProxy. I believe they work similar with JSONP getting a lot of traction if I may call it that.
    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
    Ext User
    Join Date
    Jul 2010
    Posts
    32
    Vote Rating
    0
    fgeorge is on a distinguished road

      0  

    Default


    thanks mitchell but how will i adjust the code above to achieve this cross domain call?
    i cant seem to find any example of this anywhere..

    thanks

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

    Smile


    Look at the examples. The kitchen sink demo hs a good JSONP EXAMPLE. ScripTagProxy works the same as the other Proxies
    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
    Ext User
    Join Date
    Jul 2010
    Posts
    32
    Vote Rating
    0
    fgeorge is on a distinguished road

      0  

    Default


    I have looked at this example but it only shows how to get to the remote JSON Data..not how to move it to localstorage....

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


    There is another proxy called LocalStorageProxy. This will add files to the HTML5 browser database so you will need an offline Store. Take not of the Store's sync function though.
    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.

Similar Threads

  1. Replies: 4
    Last Post: 25 Sep 2010, 11:29 AM
  2. populate comboBox using remote JSON store
    By zohaib in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 26 Nov 2009, 6:21 AM
  3. JSON store does not populate with remote data
    By Musical Shore in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 29 Oct 2009, 5:56 AM
  4. [solved] populate comboBox using remote JSON store
    By marcvs in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 14 Sep 2009, 3:59 AM

Thread Participants: 1

Tags for this Thread