-
31 Oct 2011 6:06 PM #1
hasOne Model Assocations Missing
hasOne Model Assocations Missing
REQUIRED INFORMATION
Ext version tested:
- Sencha Touch 2.0 PR1
Browser versions tested against:
- Chrome 15
Description:
- Following the Association documentation, I tried to add a hasOne association to my User model (Company). It did not populate the nested data and did not create the getters/setters for the association
Steps to reproduce the problem:
- Load User object
- Check if getCompany() returns anything
The result that was expected:
- Company would have data.
currUser.raw.company
Object
. class: "com.breakpoint.Company"
. companyLogo: null
. companyName: "Breakpoint Brokerage"
. contactAddress: "5 Main St, Brooklyn, NY 11229"
. contactPhone: "7185551212"
. dateCreated: "2011-11-01T01:24:04Z"
. endDate: "2011-12-30T05:00:00Z"
. id: 1
. isActive: true
. lastUpdated: "2011-11-01T01:24:04Z"
. numAccounts: 2
. startDate: "2011-11-01T01:24:04Z"
. users: null
. __proto__: Object
The result that occurs instead:
- TypeError: Object [object Object] has no method 'getCompany'
Test Case:
Code://User.js Ext.define('SuperQualifier.model.User', { extend : 'Ext.data.Model', fields : [{ name : "id", type : "int" }, { name : "userName", type : "string" }, { name : "email", type : "string" }, { name : "isAdmin", type : "boolean" }, { name : "passwordReset", type : "boolean" }], // assocations not implemented? associations : { type : "hasOne", model : "SuperQualifier.model.Company" }, proxy: { type:"rest", url:'../user/getUser', reader: { type: 'json', root: '' } } }) Ext.create('Ext.data.Store', { model: 'SuperQualifier.model.User' }); //Company.js Ext.define('SuperQualifier.model.Company', { extend : 'Ext.data.Model', fields : [{ name : "id", type : "int" }, { name : "companyName", type : "string" }] }) //Console Code SuperQualifier.model.User.load(1,{success: function(user) { currUser = user }}) currUser.getCompany() TypeError: Object [object Object] has no method 'getCompany'
HELPFUL INFORMATION
Debugging already done:
- none
Possible fix:
- not provided
Additional CSS used:
- only default ext-all.css
Operating System:
- Mac OSX 10.7.1
-
1 Nov 2011 8:52 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
Indeed, known issue that is on our plate to fix before release. Thank you for the report.
-
21 May 2012 5:48 AM #3
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote