Results 1 to 3 of 3

Thread: Working with ExtJs model associations

  1. #1

    Default Working with ExtJs model associations

    I am facing an issue, while implementing model associations. here are my models

    Code:
    Ext.define('EPSS.model.EventType', {    extend: 'Ext.data.Model',
        uses: [
            'EPSS.model.Event'
        ],
    
    
        idProperty: 'Id',
    
    
        fields: [
            {
                name: 'Id'
            },
            {
                name: 'Name'
            },
            {
                name: 'Color'
            },
            {
                name: 'EventId'
            }
        ]
    });
    
    Ext.define('EPSS.model.Event', {
        extend: 'Ext.data.Model',
        uses: [
            'EPSS.model.EventType'
        ],
    
    
        idProperty: 'Id',
    
    
        fields: [
            {
                name: 'Id'
            },
            {
                name: 'Name'
            },
            {
                name: 'DueDate',
                type: 'date'
            },
            {
                name: 'Status'
            },
            {
                name: 'LastModified',
                type: 'date'
            },
            {
                name: 'EventTypeId'
            }
        ],
        associations: [{
            type: 'belongsTo',
            model: 'EPSS.model.EventType',
            associatedName: 'EventType',
            instanceName: 'EventType'
        }],
    
    
        proxy: {
            type: 'rest',
            url: '/epss/api/Event',
            reader: {
                type: 'json',
                root: 'data'
            }
        }
    });
    Here is the json data

    Code:
    {
    DueDate: "/Date(1338922800000+0500)/",
      EventType: {
       Color: "green",
    Id: 1,
    Name: "Begining of Year"
    },
    EventTypeId: 1,
    Id: 1,
    LastModified: "/Date(1275332400000+0500)/",
    Name: "Event 1",
    Status: "approved" 
    }
    when I execute following line of code...

    var row = store.getAt(0);


    row.getEventType(function (event) {

    }, this);

    following exception is thrown

    Uncaught TypeError: undefined is not a function

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    You can specify the getterName config to what you want.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3

    Default create a fiddle

    still, no luck, I have create a fiddle on the following link for testing

    http://jsfiddle.net/9MR7j/3/

Posting Permissions

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