2016-04-15 11 views
0

Ich habe eine Reihe von Association funktioniert gut in 4.2.2, die jetzt nicht funktioniert in meinem Upgrade auf Version 5.1 (Kompatibilitätsmodus ist absichtlich)ExtJS Upgrade Nightmare 4.2.2 auf 5.1 (Associations funktioniert nicht !!)

Ext.define('BA.model.Betas', { 
    extend : 'Ext.data.Model', 
    fields : [ { 
     name : 'id', 
     type : 'number', 
     useNull : true 
    }, { 
     name : 'betaName', 
     type : 'string' 
    }, 
    .... 
    ], 
    belongsTo : [ { 
     name : 'model', 
     model : 'BA.model.Models', 
     associationKey : 'betas', 
     getterName : 'getModel', 
     setterName : 'setModel' 
    } ], 
    hasMany : [ { 
     name : 'securities', 
     model : 'BA.model.Securities', 
     primaryKey : 'id', 
     foreignKey : 'fk' 
    }, { 
     name : 'mappingVOs', 
     model : 'BA.model.Portfolios', 
     primaryKey : 'relId', 
     foreignKey : 'fk' 
    }, { 
     name : 'params', 
     model : 'BA.model.Params', 
     primaryKey : 'name' + 'group', 
     foreignKey : 'fk' 
    } ], 
    idProperty : 'id' 
}); 

Als ich tun store.sync() in 4.2.2, die gesamte Baumstruktur auf dem Server vorging:

[ 
    { 
    "id": 199034, 
    "betaName": "DUVACFEF", 
    "betaDesc": "DUVACFEF", 
    "region": "GLOBAL", 
    "sequencer": "", 
    "securities": [data], 
    "mappingVOs": [data], 
    "params": [data] 
    } 
] 

Aber nach dem Upgrade auf ExtJS 5.1, das wird:

[ 
    { 
    "id": 199034, 
    "betaName": "DUVACFEF", 
    "betaDesc": "DUVACFEF", 
    "region": "GLOBAL", 
    "sequencer": "", 

"fk": null

} 
] 

Bitte helfen. Was soll ich tun, um das zu beheben?

Antwort

0
Ext.data.writer.Json.override({ 
    /* 
    * This function overrides the default implementation of json writer. Any 
    * hasMany relationships will be submitted as nested objects. When preparing 
    * the data, only children which have been newly created, modified or marked 
    * for deletion will be added. To do this, a depth first bottom -> up 
    * recursive technique was used. 
    */ 
    getRecordData : function(record) { 
     return record.getData({ 
      associated : true 
     }); 
    } 
});