Extjs 5 hasMany vs field.reference

I am trying to understand the various types of data bindings in ExtJS, and I could not figure it out:

What is the difference between "hasMany" and "field.reference" when defining associations on two models?

When should you use "hasMany" and when is "link" better?

For example, if I want to define multiple email addresses for one user, what is the best practice so that I can use the email model elsewhere?

I know that I have 3 questions, but they seem to belong to each other.

Thanks!

+5
source share
1 answer

One of the best glitches in this I've seen here:

http://moduscreate.com/associations-in-ext-js-5/

It sets out and specifically addresses your third question regarding email addresses - since the association is now defined on the child model and not on the parent model, you must have a different email model if you want to connect it to another parent, that is, the CustomerEmail class for Joining the client and AdminEmail class to join the administrator.

Here are a few details due to a change here:

http://www.sencha.com/blog/deep-dive-into-ext-js-5-data

Association declarations are another area in Ext JS 5 where we have reduced code requirements. In previous releases, hasMany, and hasOne belongs to the settings that you need to manually maintain symmetrical declarations on both sides of the association. This is no longer the case. You can declare an association in related classes (although usually on the "many" side).

+8
source

Source: https://habr.com/ru/post/1201614/


All Articles