We deal with two models "customer" and "support". At this time, we have a relationship that "There is more than one support record for one customer". Parent is customer (1), child is support (N).
Let's take a look at two models, "customer" and "support".
Register new customer's data.
The "Support new creation" button is prepared on the detail display screen of the customer.(Figure 1) To register a support model that is related to a foreign key, perform the new registration from the detail display screen of the target data (here, customer data).
Click the "Create new support" button and open the support new registration screen.The customer ID (ID of the linked parent model) is automatically set.
Enter each item and register."Customer list display" and "Customer details display" button for returning to the customer model from the support detailed display screen are prepared.
Click the "Customer details display" button to open the customer details display screen.A list of support records will be displayed on the customer model side as well.
In this way, models that are related to foreign keys also have bidirectional link relationships on the screen.This will allow you to check "which records were supported by which customers".
The definition of the support model prepared this time is shown in Figure 6.
Specify the type of the item specified as the foreign key with the same type as the type of the reference (parent) item.In this example, "customer ID" is specified as "numeric" type.
The point of definition is the part that specifies that "customer ID" is a foreign key.(FIG. 7)
Specify the parent model for "foreign key> model name".
"Referenced item name" is the item on the child model side isSame nameCan be omitted.(This time it is the same "customerid", so you can omit it.)
When the external key model list display format is grid, the child model display will also be grid.
The grid display has several limitations.For details, see "Screen function> Search/List display (list display) Grid formatPlease read.
Foreign key Chain icon is displayed in the model item list for the specified item.
The display order of the child model list prepared at the bottom of the parent model's detailed display screen is the ascending order of the child model primary key. You can change this.
For example, when you create children c1, c2, c3 for parent p1, the display of the child model's screen is c1, c2, c3 by default. If "-1" is specified here in the sort order of the child model "primary key" item, it becomes c 3, c 2, c 1.
For details, see "Model definition> sortPlease read.
"Repeat container"And" foreign key "can build a 1: N relationship between the parent model and the child model.The difference between the two is as follows.
"Screen> Search/list display> Foreign key cooperation> List of data to be displayed on the detailed display screen of the parent modelPlease make sure the setting of "Enable" is enabled.