Hi Everyone!
I'm playing around with sencha and created a list with a store and a model:
main:
Ext.Loader.setConfig({enabled: true});
Ext.application({
viewport: {
autoMaximize: false
},
name: 'Sencha',
launch: function() {
Ext.create('Ext.List', {
fullscreen: true,
store: Ext.create('store.Test', {
}),
itemTpl: '{lastName}, {firstName} Age: {age}'
});
}
});
store:
Ext.define('store.Test', {
extend: 'Ext.data.Store',
model: 'model.User',
data: [
{ firstName: 'Ed', lastName: 'Spencer', age: 30 },
{ firstName: 'Tommy', lastName: 'Maintz', age: 41 },
{ firstName: 'Aaron', lastName: 'Conran', age: 24 },
{ firstName: 'Jamie', lastName: 'Avins', age: 76 }
]
});
model:
Ext.define('model.User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' }
]
});
To this point everything works fine.
Then I created a second store, which has another field 'age'. What I want now is to pass a parameter 'model' to the store to be able to "switch" between different
models. I tried something like this:
store:
Ext.define('store.Test', {
extend: 'Ext.data.Store',
myModel: null,
constructor : function(model) {
myModel = model;
},
model: this.myModel,
data: [
{ firstName: 'Ed', lastName: 'Spencer', age: 30 },
{ firstName: 'Tommy', lastName: 'Maintz', age: 41 },
{ firstName: 'Aaron', lastName: 'Conran', age: 24 },
{ firstName: 'Jamie', lastName: 'Avins', age: 76 }
]
});
and in the main file:
[...]
store: Ext.create('store.Test', {
model: 'model.UserWithAge'
}),
[...]
But Google Chrome gives me:
Uncaught TypeError: Object [object Object],[object Object],[object Object],[object Object] has no method 'getRange'
Any hints what I've done wrong?
Thanks in advance!
AVADHESH PATEL
01-Jun-2013