1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    21
    Vote Rating
    0
    K4T is on a distinguished road

      0  

    Default Answered: Many assocations to one model

    Answered: Many assocations to one model


    Hello! I have task model which have two associations to one model - User model. Those associations create two getters for me: getAssignedTo() and getAssignedBy() which should allow me to get users names by id (foreign keys). I think those associations are collide and I dont know how to resolve this. For example:

    Code:
            console.log(record);
    
            record.getAssignedTo(function(user, operation) {
                console.log('Assigned To: ' + user.get('name'));
            }, this );
    
    
            record.getAssignedBy(function(user, operation) {
                console.log('Assigned By: ' + user.get('name'));
            }, this );
    That example will log:

    gacq.jpg

    As you see getAssignedBy() returns empty string :/ If I remove accocation for assignedToId foreign key than getter getAssignedBy() will work because there is only one assocation to User model inside Task model. How I can resolve this issue?

    Task Model:
    Code:
    Ext.define('Tasks.model.Task', {
        extend: 'Ext.data.Model',
    
    
        fields: [
            {name: 'id',            type: 'int'},
             ...
            {name: 'assignedToId',  type: 'int',        defaultValue: 1}, //default value for simulating logged user
            {name: 'assignedById',  type: 'int',        defaultValue: 1}  //default value for simulating logged user
        ],
    
    
        associations: [
            { type: 'belongsTo', model: 'Tasks.model.User', primaryKey: 'id', foreignKey: 'assignedToId', getterName: 'getAssignedTo' },
            { type: 'belongsTo', model: 'Tasks.model.User', primaryKey: 'id', foreignKey: 'assignedById', getterName: 'getAssignedBy' }
        ],
    
    
        proxy: {
            ...
        }
    
    
    });
    User Model:
    Code:
    Ext.define('Tasks.model.User', {
        extend: 'Ext.data.Model',
    
    
        fields: [
            {name: 'id',    type: 'int'},
            {name: 'name',  type: 'string'}
        ],
    
    
        hasMany: {model: 'Tasks.model.Task', name: 'tasks'},
    
    
        proxy: {
            ...
        }
    
    
    });


  2. #2

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."