PDA

View Full Version : Ext data store require full model name for model config



vcraescu
4 Oct 2011, 12:32 AM
Ext.define('EM.store.PeopleTree', {
extend: 'Ext.data.TreeStore',
model: 'EM.model.Person',

root: {
Full_Name: 'My Root',
cPeople_ID: 0
},

nodeParam: 'cPeople_ID',

autoLoad: true,
autoSync: true,
folderSort: true,

listeners: {
load: function(self, node, records, successfull, eOpts) {
}
}

});

The code from above works.

Ext.define('EM.store.PeopleTree', { extend: 'Ext.data.TreeStore',
model: 'Person',

root: {
Full_Name: 'My Root',
cPeople_ID: 0
},

nodeParam: 'cPeople_ID',

autoLoad: true,
autoSync: true,
folderSort: true,

listeners: {
load: function(self, node, records, successfull, eOpts) {
}
}

});

It doesnt work. Model config property require full model name. Anyone have any ideea why? The app use the recommended directory structure and this is the only place inside my app where i have to specify the full name for a class.

lucasguaru
4 Oct 2011, 10:57 AM
I never tried this but did you try adding the model to the controller?

//the Users controller will make sure that the User model is included on the page and available to our app
Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users'],
models: ['User'],
...
});

// we now reference the Model instead of defining fields inline
Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',

data: [
{name: 'Ed', email: 'ed@sencha.com'},
{name: 'Tommy', email: 'tommy@sencha.com'}
]
});
In sencha example, they use it there but they use the model full name on the store.

vcraescu
4 Oct 2011, 7:40 PM
Yes, it was added to controller.
I saw their example, but why do we need to use full class name? It's very confusing...

brokentwig
4 Oct 2011, 8:14 PM
Not sure what example you are referring to, but most of the Sencha examples do not use the MVC structure. I reference the Model using it's whole name as well.

vcraescu
4 Oct 2011, 8:52 PM
I know Sencha examples don't make use of MVC structure because are just simple examples. For complex applications it's good to have a nice structure in place and follow the conventions which will pay for itself later on during the development.

lucasguaru
5 Oct 2011, 5:50 AM
I'm following the MVC Application Architecture on
http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture

I agree with you. Would be better to follow the rules for controller, views, etc, just using the name, once you're following the recommended directory structure.
Maybe they didn't think about this.

vcraescu
5 Oct 2011, 6:03 AM
This would be very weird...
Such a nice and complex framework and they missed such an obvious thing? I bet there is a better explanation...

diovani
28 Dec 2011, 5:56 AM
Is there realy a reason for this?

Otherwise we could open a bug thread.