Results 1 to 6 of 6

Thread: Weird naming convention using model and store?

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    18
    Vote Rating
    2
      0  

    Default Weird naming convention using model and store?

    Dear all,

    I'm using MVC. Recently I encountered a problem loading a model for a store, getting a naming error:

    Code:
    Ext.application({
        name: 'Test',
        views: ['MyView'],
        models: ['MyModel'],
        stores: ['MyStore'],
        launch: function() {
            Ext.Viewport.add(Ext.create('Test.view.MyView'));
        }
    });
    
    
    Ext.define('Test.model.MyModel', {
        extend: 'Ext.data.Model',
        config: {
            fields: ...
        }
    });
    
    Ext.define('Test.store.MyStore', {
        extend: 'Ext.data.Store',
        config: {
            model: 'MyModel', // error - instead 'Test.model.MyModel' is required ...
            ...
        }
    });
    
    Ext.define('Test.view.MyView', {
        extend: 'Ext.DataView',    
        config: {
            store: 'MyStore',
            itemTpl: ...
        }    
    });
    In the DataView declaration the abbreviation 'MyModel' is fine but for the Store declaration this results in an error "MyModel does not exist". Replacing MyModel with Test.model.MyModel fixes the problem. For me, this seems to be inconsistent. Or is there another error in my code?

    -Niko

  2. #2
    Sencha User Brett Hannah's Avatar
    Join Date
    Oct 2012
    Location
    London
    Posts
    24
    Answers
    1
    Vote Rating
    6
      0  

    Default

    Hi Niko,

    I haven't tested your code but a cursory glance would suggest that the error lies in your definition of the Store.

    You have extended Ext.data.Model instead of Ext.data.Store

    Best regards,
    Brett Hannah
    LinkedIn
    EdgeUX
    Brett Hannah LinkedIn
    EdgeUX

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    18
    Vote Rating
    2
      0  

    Default

    Just a typo in the example code ... Sorry. Problem remains.

  4. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
      0  

    Default

    Hi Niko,

    did you require your model anywhere in your code?
    You can do this either in your app.js or in your store. With the help of the "require" you make sure that the given files are loaded and available for further using.

    I can imagine that something like
    Code:
    Ext.define('Test.store.MyStore', {
        extend: 'Ext.data.Store',
        requires: [
            'Test.model.MyModel'
        ],
        config: {
            model: 'MyModel',
            ...
        }
    });
    will fix the problem.

    Best regards,
    Schildi

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    18
    Vote Rating
    2
      0  

    Default

    Hi Schildi,

    Yes, I did, in app.js. I added this also to my code example.

    -Niko

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    134
    Answers
    6
    Vote Rating
    5
      1  

    Default Are the names correct in the Application

    Shouldn't the models and stores in the Application be : MyModel and MyStore?

Posting Permissions

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