-
4 Nov 2011 11:30 AM #1
Answered: Did belongsto works with dots ?
Answered: Did belongsto works with dots ?
Hello everybody.
BelongsTo don't works with model like: Appname.model.ModelName.
two classes to make tests - http://pastebin.com/jE5rkfmWHTML Code:Ext.define('Panda.model.Product', { extend: 'Ext.data.Model', fields: [ { name: 'id', type: 'int' }, { name: 'manifactor_id', type: 'int' }, { name: 'name', type: 'string' } ], associations: [ { type: 'belongsTo', model: 'Panda.model.Manifactor', 'name' : 'manifactor', }] });
Is it possible to make it's works ?
Or don't use associations at all ?
-
Best Answer Posted by whalethewise
I use it like this and it works for me:
Code:Ext.define('com.MyApp.model.Document', { extend: 'Ext.data.Model', fields: documentModelMainFields, hasMany: { model: 'com.MyApps.model.Attribute', name: 'attributes' } }); Ext.define('com.MyApp.model.Attribute',{ extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'float'}, {name:'name'}, {name: 'value'}, {name: 'document_id', type: 'float'} ], belongsTo: { model: 'com.MyApp.model.Document', foreignKey: 'document_id' } });
-
4 Nov 2011 11:37 AM #2Ext JS Premium Member
- Join Date
- Jun 2011
- Location
- Ottawa, Ontario, Canada
- Posts
- 123
- Vote Rating
- 1
- Answers
- 3
I use it like this and it works for me:
Code:Ext.define('com.MyApp.model.Document', { extend: 'Ext.data.Model', fields: documentModelMainFields, hasMany: { model: 'com.MyApps.model.Attribute', name: 'attributes' } }); Ext.define('com.MyApp.model.Attribute',{ extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'float'}, {name:'name'}, {name: 'value'}, {name: 'document_id', type: 'float'} ], belongsTo: { model: 'com.MyApp.model.Document', foreignKey: 'document_id' } });
-
4 Nov 2011 12:07 PM #3
if i change
toHTML Code:associations: [ { type: 'belongsTo', model: 'Panda.model.Category' }, ]
p = new Pandora.model.Product()HTML Code:belongsTo: { model: 'Pandora.model.Category', foreignKey: 'id', name: 'category', }
p.associations.keys - get the right value.
But how to get a category ?
p.getCategory - return error function underfined
-
4 Nov 2011 5:24 PM #4
found getterName parameter in source code belongto.js
getterName : 'getCategory'.
thats i needed.


Reply With Quote