RelationshipOneToMany - EtheaDev/kitto2 GitHub Wiki
How to define a "Has Many" reference between models
Please refer to here for general information about models.
If you define a "Has Many" reference between models, you are creating a Master/Detail relationship. You have to operate in both master and detail models:
- Master model: define the
DetailReferencesnode listing detail references - Detail model: define a reference field that points back to the master model.
Example from HelloKitto:
# model Party.yaml
ModelName: Party
...
DetailReferences:
Invitations: Invitation
# model Invitation.yaml
ModelName: Invitation
Fields:
...
Party: Reference(Party) not null
Fields:
Party_Id:
In order to render the master/detail relationship between data, you have to define the MainTable/DetailTables node in the view as following:
# view parties
Type: Data
...
MainTable:
Model: Party
.......
DetailTables:
Controller:
# Tabs/Popup/Bottom. Default = Tabs.
Style: Bottom
Height: 250
Table:
Model: Invitation
Fields:
Invitation_Id:
Party:
IsVisible: False
Invitee:
Accepted: