Workbench User Guide : Generating Frames from Predefined Templates : The mastdetl Templates : The master_detail Template
 
Share this page          
The master_detail Template
Like the simple_field and table_field frame templates, the master_detail frame template creates a database table browser. However, master-detail frames perform two queries that exist in a one-to-many master-detail entity relationship. The master query, which queries one or more joined tables, is used to populate the master portion of the frame; the detail query, which can also query one or more joined tables, is used to populate the detail portion of the frame.
Note:  Frames generated from this template can call frames generated from the detail or explosion frame templates.
Create a Master-Detail Frame
You can create a master-detail frame using the master_detail frame template.
To create a frame using the master_detail frame template
1. On the Develop tab, select the application in which you want to create the frame in the Applications portlet, and then select the header bar of the Components portlet to make it active.
2. Click File, New, User Frame.
The Create User Frame dialog appears.
3. Enter the component name in the Name field (for example, My_Master_Detail).
4. (Optional) Enter a comment for the component in the Remark field.
5. Select mastdetl from the Application list and the master_detail template from the Template list.
6. Click Create.
The Select Database Object dialog appears.
Note:  The Select Database Object dialog displays two entry fields instead of the usual one.
7. Enter the name of the primary master table in the Master entry field.
8. Repeat this procedure for the primary detail table using the Detail entry field.
For more information about using the control button to the right of the entry field to specify a table, see Table Selection Dialog.
9. Click OK.
The Frame Assistant appears:
10. Click the join icon in the query display area.
11. Before generating the master-detail frame, you must define one or more join columns between the two tables. Then click Insert to create a join.
A line is drawn between the two columns indicating the join.
For more information, see How You Can Define Join Column Properties.
12. Using the Frame Assistant, you can optionally specify additional tables, including lookup or associate tables. You can also select query expressions, query properties, and display properties for result columns.
For more information, see:
How You Can Set Query Expressions)
How You Can Set Query Properties)
How You Can Set Display Properties)
Add Additional Tables to a Generated Frame)
13. Click Generate.
If the tables you specified have “updatable” columns but no key, an Information dialog appears.
14. Click OK to continue.
The master-detail frame is created and displayed in the Frame Editor.
Note:  An Open Row and an Open List button are provided in the Frame Editor. They will appear in the running frame only if the master-detail frame is selected as the parent frame to either an explosion or a detail frame (for more information, see Create an Explosion Frame) or Create a Detail Frame).
15. (Optional) Specify the frame's properties using the Property Inspector.
For more information about using the Property Inspector, see Set Frame Properties.
How You Can Use a Master-Detail Frame
The generated master-detail frame displays a master and a detail section. The master section of a frame is used to display a single row passed to it from a calling frame's detail table field. It consists of a set of VCR buttons and a slider to navigate through each selected row, with its values updated automatically in a matrix of fields. Each field is mapped by name and type to the result columns of the master query.
The detail section of a detail frame is used to display the rows of a second query of one or more joined tables that are associated with the master query. It contains a table field, each of whose columns maps by name and type to the result columns of the detail query.
To see the master-detail frame in operation, click Debug, Go on the floating menu bar.
Master Query Table Operations
The Form menu provides commands to enable the user to perform standard database operations on the master query table, such as inserting a new row, duplicating a row, and saving the changes to the table. It also enables you to perform a query or sort the data in the master-detail frame. For more information about sorting and querying, see How You Can Use a Simple Field Frame.
Detail Query Table Operations
As the user is navigating between rows of the master query, the table field in the detail section of the frame is automatically populated with those rows in the detail query associated with the current row in the master section. The Row menu commands also perform standard database operations on the detail database table, such as adding a new row, duplicating a row, finding text, and copying the table. (For more information about how to find text and copy a table, see Use a Table Field Frame).
A new table can also be created by clicking Form, New. To enter new data, click the control button and select Create First Row. For information about editing data in a table, see Use a Table Field Frame.
Synchronous or Asynchronous Frame Processing
In the master-detail frame, keeping the data in the parent and explosion or detail (child) frames “in sync” could be a tedious job. However, using The OpenROAD frame templates, it is handled seamlessly by the frame's synchronization mode.
By default, the generated frame is synchronous, which means that the parent and child frames are both updated when a change is made in either frame. In asynchronous mode, the parent and child frames operate independently.
To make the frame asynchronous, click the control button and then clear Synchronous Detail Frame from the option menu, removing the checkmark.
When the parent frame is in asynchronous mode and the explosion or detail frame is displayed, its VCR buttons do not appear. There is no need for the parent and child to remain synchronized, so these buttons are not necessary. Thus, the presence of the VCR buttons on the explosion or detail frame is dynamic, depending on a selection made at runtime.