PDA

View Full Version : [OPEN] [4.1b2] MVC 'model' property bug



keckeroo
15 Feb 2012, 10:54 AM
From my understanding, the 'models' is like writing 'requires' with 'MyApp.model' automatically prefixed to the model name as documented in the APIs.

This appears not to be the case when accessing models from within the application launch function itself. I'm going to assume this also extends to stores as well.




Ext.Loader.setConfig({ enabled: true });

Ext.application({
name: 'MyApp',

WORKS --> requires: [ 'MyApp.model.Category' ],
DOESN'T WORK --> models: [ 'Category' ],

launch: function() {

new Ext.data.Store({
model: 'MyApp.model.Category',
storeId: 'CategoryList',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data/json.json',
reader: {
type: 'json',
root: 'apiRecords'
}
}
});

new Ext.container.Container({
renderTo : document.body,
width : 400,
height : 400,
items : [
{
xtype: 'combobox',
triggerAction: 'all',
store: 'CategoryList',
width: 300,
queryMode: 'local',
valueField: 'categoryid',
displayField: 'description',
editable: false
}
]
});
}
});


app/model/Category.js:



Ext.define('MyApp.model.Category', {
extend : 'Ext.data.Model',

fields : [ 'categoryid', 'description' ]
});


data/json.json



{
"apiRecords" : [
{ "categoryid" : 1, "description" : "One" },
{ "categoryid" : 2,"description" : "Two" },
{ "categoryid" : 3, "description" : "Three" },
{ "categoryid" : 4, "description" : "Four" }
]
}

mitchellsimoens
15 Feb 2012, 11:12 AM
All it does is create the getter method to get the class definition so you can create a model instance but the docs say that it should require them.