ExtJs 4.2.2 HasMany Association Bug

Posted By Vitaliy | February 19, 2014 | ExtJS 4.2.2
0 4181
This type of association represents a one-to-many relationship between two models.
For example OOP Class has many Properties.

As you can see class properties were not loaded as here. And this is a bug in 4.2.2. Forum thread is here.

See how it works on ExtJS 4.1.1 here.

Js Code

Ext.define('Class', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'name', type: 'string' }
    ],
    hasMany: {
        model: 'Property',
        name: 'properties',
        associationKey: 'properties',
        primaryKey: 'id',
        foreignKey: 'classId'
    },
    proxy: {
        type: 'rest',
        url: '/api/classes'
    }
});

Ext.define('Property', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'classId', type: 'int' },
        { name: 'name', type: 'string' }
    ],
    proxy: {
        type: 'rest',
        url: '/api/properties'
    }
});
            

ExtJs 4.1.1 HasMany Association

Posted By Vitaliy | February 19, 2014 | ExtJS 4.1.1
0 3843
This type of association represents a one-to-many relationship between two models.
For example OOP Class has many Properties.

See how it works on ExtJS 4.2.2 here.

Js Code

Ext.define('Class', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'name', type: 'string' }
    ],
    hasMany: {
        model: 'Property',
        name: 'properties',
        associationKey: 'properties',
        primaryKey: 'id',
        foreignKey: 'classId'
    },
    proxy: {
        type: 'rest',
        url: '/api/classes'
    }
});

Ext.define('Property', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'classId', type: 'int' },
        { name: 'name', type: 'string' }
    ],
    proxy: {
        type: 'rest',
        url: '/api/properties'
    }
});