PDA

View Full Version : Unless you define your model through metadata, a store needs to have a model defined



dirtdevil
25 Aug 2013, 2:34 PM
"Unless you define your model through metadata, a store needs to have a model defined on either itself or on its proxy"

I keep getting that warning when I try to use a store. I did a search on the forums for that warning and read the couple of posts on it and I tried what they did in the posts but I'm still getting the error. What am I doing wrong. I know it's something so simple but I have no idea what it is. I also checked the docs on Ext.data.Store and Ext.data.Model. Here is my code...


Ext.application({
name: 'Qz',
appFolder: '/js/app',
models: ['Question'],
stores: ['Questions'],
views: ['QuestionPanel'],
controllers: ['Boot'],
launch: function() {
Ext.Viewport.add({
xtype: 'tabpanel',
fullscreen: true,
tabBarPosition: 'bottom',
items: [{
title: 'my bla',
iconCls: 'home',
xtype: 'questionpanel'
}]
});
}
});



Ext.define('Qz.model.Question',{
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'id',
type: 'int'
},{
name: 'category'
},{
name: 'question'
},{
name: 'correct'
},{
name: 'answers'
}]
}
});



Ext.define('Qz.store.Questions',{
extend: 'Ext.data.Store',
config: [{
model: 'Qz.model.Question',
data : [{
id: 23,
category: 'question category',
question: 'where is this and that?',
correct: 'A',
answers: [{
id: 'A',
label: 'my first answer'
},{
id: 'B',
label: 'my second answer'
},{
id: 'C',
label: 'my third answer'
}]
}]
}]
});

p.s. I replied to another post with my issue but I can't find it anymore. Thats why I'm making a new post.

dirtdevil
25 Aug 2013, 3:10 PM
Ug, I just noticed I accidently posted this in the ext js forum and this is actually a sencha touch 2.2 issue. Can one of the admins please move this thread to the right place? thanks.

dirtdevil
25 Aug 2013, 5:02 PM
omg, nevermind. I found the problem. I'm passing config as an array instead of an object. All is well.


Ext.define('Qz.store.Questions',{
extend: 'Ext.data.Store',
config: [{
model: 'Qz.model.Question',
data : [{
id: 23,
category: 'question category',
question: 'where is this and that?',
correct: 'A',
answers: [{
id: 'A',
label: 'my first answer'
},{
id: 'B',
label: 'my second answer'
},{
id: 'C',
label: 'my third answer'
}]
}]
}]
});

Gary Schlosberg
27 Aug 2013, 4:42 AM
Great to hear that you found your answer, and thanks for posting it. I've moved this thread to the Touch forum as requested.