PDA

View Full Version : how to create a new record with associations?



MarcusPetri
15 Apr 2016, 6:23 AM
I have two differents, but similar, models with the same associations, when I try to create a new record from one of these similar models, it does not 'copy' associations.

I have the same associations in both models.


record_updated =Ext.create('Suite.model.ProjTask', record.getData(true))my record.getData(true) object:
54385

and the new record_updated object:
54386

Jad
15 Apr 2016, 7:02 AM
Hy,

I have the same issue, so i set the associations records manually

any best method appreciate ;-)

MarcusPetri
15 Apr 2016, 8:15 AM
yeah...Im using this:


record_updated.associations.each(function(association) { if (typeof record.getAssociatedData()[association.instanceName] != 'undefined') {
record_updated[association.instanceName] = Ext.create(association.model, record.getAssociatedData()[association.instanceName]);
}
});

---

I pressed unintentionally and scored your answer as the best.... haha