Add a detail list to the form
Add a list to your form and create the master-detail relationship.
A Genero application can display a form that contains a master-detail relationship between two tables. The user can search for a row in the master table, and the corresponding rows in the detail table will also be displayed. The values in rows from both tables can be added, deleted, or modified.
The form must contain fields from both tables and the table relationships must be set.
- Open the accounts.4fdm file and select the Form tab.
-
Enlarge the grid by dragging its middle circle downwards.
Figure: Expand grid in form
-
Select Container > Data Control.
The Extend Form from Database dialog displays, showing the Column Selection page.
-
Add fields from the Orders table:
- Select the officestore database and the orders table.
-
Select these fields:
orderid
,userid
,orderdate
,totalprice
, andcreditcard
. - Use the single right arrow to add these fields to the Selected Fields list.
- Click Next.
-
Select Table as the container, and click
Finish.
The cursor is set to allow you to place your container on the form.
-
Draw the container within the enlarged grid, under the existing fields.
This form design now contains fields from both the accounts and orders tables.
Figure: Form tab
- Select the Records tab.
-
Select record1. In the Properties view, change
name to account_record. Ensure
the active property is checked and the unique key
is account.userid.
Tip:
The unique key is identified by the key icon.
Figure: Account table record
-
Select record2. Change its name to
order_record. Ensure the active property is
checked and the unique key is
orders.orderid.
Figure: Order table record
-
Set the relationship between the account and order records. Right-click the
orders.userid field in the order_record table record, and select
Add Relation To. Drag the arrow to point to the
account.userid in the account_record.
Figure: Master-detail relationship
account_record
is now the Master record, andorder_record
is the detail record. - Select File > Save All to save the project and the modifications to its contents.
- In appflow.4ba, right-click the Main program entity and select Build Program.
-
Right-click the Main program
entity and select Execute Program.
Figure: The application executes
- Navigate around the database using the top menu icons. When you are finished, select File > Exit.