Results 1 to 3 of 3

Thread: Associated Model not being initialized and Getter not being created Ext.data.Model

  1. #1
    Ext GWT Premium Member
    Join Date
    May 2010
    Location
    Ashburn, Virginia
    Posts
    48
    Answers
    8

    Default Answered: Associated Model not being initialized and Getter not being created Ext.data.Model

    Been working with an associated model and trying to get it to load per the Data Package docs but so far can only load the top level model. The raw content has the correct information in it hence i believe i must be doing something wrong in the model definitions hence any information would be appreciated.

    BaseModel
    Code:
    Ext.define('Imms.model.BaseModel', {
        extend:'Ext.data.Model',
    
    
        config: {
            idProperty:'Id'
        },
    
    
        fields:[
            { name:'Id', type:'string' },
            { name:'__type', type:'string'},
            { name:'IMMSDataModelType', type:'string'}
        ]
    });
    ProblemCauseType Model
    Code:
    Ext.define('Imms.model.ProblemCauseType', {
        extend:'Imms.model.BaseModel',
    
    
        fields:[
            { name:'Code', type:'string'},
            { name:'Name', type:'string'}
        ],
    
    
        associations:[
            { type:'hasMany', model:'ProblemCause', name:'Causes'}
        ],
    
    
        proxy: {
            type: 'rest',
            url: 'data/problemcausetypes.json',
            reader: {
                type: 'json'
            }
        }
    });
    ProblemCause Model
    Code:
    Ext.define('Imms.model.ProblemCause', {
        extend:'Imms.model.BaseModel',
    
    
        fields:[
            { name:'Code', type:'String'},
            { name:'Name', type:'string'}
        ],
    
    
        associations:[
            { type:'belongsTo', model:'ProblemCauseType', name:'CauseType'}
        ]
    });
    JSON being loaded into the Models
    Code:
    [
        {
            "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
            "Id":"3e3e374c-0dba-42b9-bc8f-6ff1250a5729",
            "Name":"Internal",
            "Code":"",
            "Causes":[
                {
                    "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                    "Id":"c6914a3a-d802-4220-979c-d8d36b2dde46",
                    "Name":"Software Failure",
                    "Code":"",
                    "CauseType":{
                        "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                        "IMMSDataModelType":"ProblemCauseType",
                        "Id":"3e3e374c-0dba-42b9-bc8f-6ff1250a5729"
                    },
                    "IMMSDataModelType":"ProblemCauseDetails"
                },
                {
                    "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                    "Id":"8f7d5674-0c91-4279-994c-f40568ff6fcb",
                    "Name":"Hardware Failure",
                    "Code":"",
                    "CauseType":{
                        "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                        "IMMSDataModelType":"ProblemCauseType",
                        "Id":"3e3e374c-0dba-42b9-bc8f-6ff1250a5729"
                    },
                    "IMMSDataModelType":"ProblemCauseDetails"
                }
            ],
            "IMMSDataModelType":"ProblemCauseTypeDetails"
        },
        {
            "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
            "Id":"dc59d21c-5256-4a63-aa9d-a44f53eb2dc5",
            "Name":"vl_TestProblemCauseType",
            "Code":"",
            "Causes":[
                {
                    "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                    "Id":"7c70ceff-a001-494f-9179-03f2e4769d8c",
                    "Name":"vl_TestProblemCause",
                    "Code":"56789",
                    "CauseType":{
                        "__type":"DTOSerializer:#IMMSDataService.Core.DTO",
                        "IMMSDataModelType":"ProblemCauseType",
                        "Id":"dc59d21c-5256-4a63-aa9d-a44f53eb2dc5"
                    },
                    "IMMSDataModelType":"ProblemCauseDetails"
                }
            ],
            "IMMSDataModelType":"ProblemCauseTypeDetails"
        }
    ]
    Console output looks like this:

    Code:
    Array[6]
    
    
    • 0: constructor
      • data: Object
        • Code: ""
        • IMMSDataModelType: "ProblemCauseTypeDetails"
        • Id: "36deae12-cef1-4285-8625-239d584bc1fb"
        • Name: "External"
        • __type: "DTOSerializer:#IMMSDataService.Core.DTO"
        • __proto__: Object
      • dirty: false
      • events: Object
      • hasListeners: HasListeners
      • id: "Imms.model.ProblemCauseType-36deae12-cef1-4285-8625-239d584bc1fb"
      • index: 0
      • internalId: "36deae12-cef1-4285-8625-239d584bc1fb"
      • modified: Object
      • phantom: false
      • raw: Object
        • Causes: Array[4]
          • 0: Object
            • CauseType: Object
            • Code: ""
            • IMMSDataModelType: "ProblemCauseDetails"
            • Id: "be0611d6-be1d-4121-a983-44c342620286"
            • Name: "Vandalism"
            • __type: "DTOSerializer:#IMMSDataService.Core.DTO"
            • __proto__: Object
          • 1: Object
          • 2: Object
          • 3: Object
          • length: 4
          • __proto__: Array[0]
        • Code: ""
        • IMMSDataModelType: "ProblemCauseTypeDetails"
        • Id: "36deae12-cef1-4285-8625-239d584bc1fb"
        • Name: "External"
        • __type: "DTOSerializer:#IMMSDataService.Core.DTO"
        • __proto__: Object
      • store: constructor
      • stores: Array[1]
      • __proto__: TemplateClass
    • 1: constructor
    • 2: constructor
    • 3: constructor
    • 4: constructor
    • 5: constructor


  2. #2

  3. #3
    Ext GWT Premium Member
    Join Date
    May 2010
    Location
    Ashburn, Virginia
    Posts
    48
    Answers
    8

    Default

    Not a bug after all more of a documentation / reading of documentation issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •