Results 1 to 2 of 2

Thread: Ext.list with REST proxy type, load using model or store?

  1. #1
    Sencha User luisparada's Avatar
    Join Date
    Nov 2007
    Location
    Venezuela
    Posts
    95
    Answers
    2

    Default Answered: Ext.list with REST proxy type, load using model or store?

    Hi dear sencha developers.
    I have a question about best approach when using lists in a sencha touch 2 app.
    I'm following the MVC architecture pattern but now I have a small issue about using a list with a store which proxy is of type REST

    I found in several sencha documents that we can use directly the model to load data from the server or to the server using REST this is an example:
    Code:
    // Load User 1 and do something with it (performs a GET request to /users/1)
    User.load(1, {
        success: function(user) {
            console.log("Loaded user 1: " + user.get('name'));
        }
    });
    So what happen when we have to use Lists which needs a store ?
    My model uses a REST proxy because I'm using a Restfull API, so the way we can consume such services is sending requests or data in the url format:
    Code:
    /url/var/value => /blabla.com/api/users/2
    Where 2 is the ID of the user for example.

    So using a store will send params like this:
    Code:
    http://wwww.url.com/api/users?id=2
    But in order to use a list I need to use this store to fill the view with records.

    So what should I do now?
    Should I override store buildUrl method? is this something that will work when I move my app to a native android environment? is this compatible with phonegap?

    Should I use model.load(1) in order to keep my Restfull querying methods and use everything as it is out of the box, and then create a model instance and pass all just created records by hand to the store?

    which will end in something like this:

    Code:
    // Load User 1 and do something with it (performs a GET request to /users/1)
    User.load(1, {
        success: function(user) {
            liststore.add(user);
        }
    });
    ____________________________________
    do not make install, just compile it.!!!
    --------------------------------------------------
    //*************k4m1k4z3************\\

  2. A List displays multiple records so you will need to use a store to hold the multiple records. Loading a model will not achieve the results you want.

    If you have the proxy defined on the model, that's fine. If you do not define one on the store, the store will use the proxy defined on the model but will still handle loading the multiple records.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,447
    Answers
    3997

    Default

    A List displays multiple records so you will need to use a store to hold the multiple records. Loading a model will not achieve the results you want.

    If you have the proxy defined on the model, that's fine. If you do not define one on the store, the store will use the proxy defined on the model but will still handle loading the multiple records.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •