Amy
Amy

Reputation: 219

How to assign a record to associated model in ExtJs?

I have a model Comment, which "hasOne" model UserDigest. For some reason, I want to load the UserDigest else where and then put it into the correspond Comment. Do something like this:

comment.userDigest().setData(userDigest.getData());

But I cannot find a method like that. Can someone tell me how to set an existing record as the data of associated model ?

Or how to assign an existing model to associated model? Something like this:

comment.userDigest = userDigest; 

Upvotes: 3

Views: 1522

Answers (1)

Neil McGuigan
Neil McGuigan

Reputation: 48236

there should be a comment.setUserDigest() method auto-created for comment, when you setup the relationship.

if you use namespaces for your models then you will have to set the setterName property in the relationship, where you can set it as setUserDigest

this only sets the foreign value though, and you will probably want to set the instance as well. you may have to change the name and instanceName of the relationship too.

please read this:

http://extjs-tutorials.blogspot.ca/2012/05/extjs-belongsto-association-rules.html

Upvotes: 1

Related Questions