Results 1 to 8 of 8

Thread: How to get a single model

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Vote Rating

    Default Answered: How to get a single model

    I would like to input on how to best handle a situation. I have a store of users and a corresponding user model. The proxies for each are different - I assume Sencha will use the store proxy when I need a collection and the model proxy when I just need one?

    In my app I sometimes need to get a user that may not be in my current store collection. So I want to download it directly and add it to the store. Unsure how to do this.

    User model:
    Ext.define("App.model.User", {
        extend: "",
        config: {
            fields: ['id', 'name'],
            proxy: {
                type: 'ajax',
                url : config.url + "/user",
                reader: 'json'

    Users store:
    Ext.define("", {
        extend: "",
        requires: "App.model.User",
         config: {
             autoLoad: true,
             model: "App.model.User",
             proxy: {
                type: 'ajax',
                url : config.url + "/users",
                reader: 'json'

    In my controller code - this doesn't work
    var d ='Users');
    var e = d.find('id', 'someid');
    if(e == -1) {

    Errors are get:
    Uncaught Error: [ERROR][] An Operation needs to have a model defined. (if I try to call load on store instead of find)
    Uncaught TypeError: Cannot call method 'load' of undefined (if I try to use modelmanager)

    So how can I fetch a user by id from store and have the model automatically fetch it from proxy if not found?


Posting Permissions

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