Support > Repository > Parent-child relationship > Display the child model list using item values ​​other than the parent key

The child model displayed on the parent model screen is usually narrowed down by the parent key. Specifying this condition individually makes it possible to display the child model list even if the parent key is not set yet. R7.12

We will explain it using an example in which the "weekly report" model is a parent and the "action plan" model is a child.

Normally, the action plan model holds the key of the weekly report model that is your parent as (as a foreign key).However, as can be seen from Figures 1 and 2, the foreign key "Weekly ID" has not been set yet.

Actually, in this sample application, data that "activity date" of the action plan (child) is included in the "start date" and "end date" of the weekly report (parent) is displayed as a list.The logon account in Fig. 1 is "Sato", the logon account in Figure 2 is "Yamada", but because the weekly report ID has not been set, it is displayed as the child model of each weekly report (same action plan data) You can see that.

Figure 1 Weekly report of logon account "Sato"
Figure 2 Weekly report of logon account "Yamada"

For this reason, when formulating the action plan, it is possible to newly register data while keeping "which Weekly report linked" not set.While operating, you specify the parents to be connected, but you can also make changes.Still, as a child model of the weekly report (parent), you can display action plan (child) by narrowing down by period.

Confirm the weekly report (parent)

Figure 3 shows an example of setting a weekly report ID (parent's primary key) for one of the action plan data.The action plan (child) is displayed in the weekly report with weekly report ID "1001" (this is the weekly report of "Yamada").

Fig. 3 When weekly report ID is determined

In the weekly report of "Sato", this data will not be displayed.

Figure 4 Weekly report of "Sato"

System administrator can view all data

Please note that all data can be viewed by the system administrator.

Figure 5 System administrator

Week report model and action plan model

In this application, the weekly report model is parent and the action plan model is child.

Fig. 6 Week report model and action plan model

In the action plan model, you can see that the weekly report ID is a foreign key.

Figure 7 Foreign key setting

Script settings (parent)

"Weekday" start date "is set in the p.request object when detailed display of weekly report (parent) is processed.

Figure 8 Hellpa script for detail display (parent)
if (parent !== null) {
    var s = parent.begindate;
    p.request.setAttribute("begindate", s);
}

Setting of implicit condition (child)

In the action plan model, set the actiondate item as the search condition.At this time "range search" isInvalidwill do.

The narrowing-down condition is set using the set value "begindate".

(java.sql.Date)ATTRIBUTE("begindate")
Figure 9 Setting Implicit Conditions (Child)

About the ATTRIBUTE function 7.12

In this example, "order" is important, in which the beforeShow method of the parent helper class is called during a single process, followed by the listing of the children.According to this order, "parental processing" sets "start date" information in p.request, and "start date" is used in child list display (rule of implicit condition used for).At this time, you can obtain the value using the ATTRIBUTE function.

The ATTRIBUTE function can be described as an implicit condition.

Restriction

  • When doing this setting, you can not use the grid format to display the list of child models.