In this Oracle Apex tutorial, I will show you how to create a master-detail form/interactive grid manually. Wondering why manually? When there is an option to create it through the wizard in Oracle Apex. It is because, when you create the master-detail form through the wizard, you do not know the settings that happened behind to create the master-detail relationship between the tables. And when you will create the master-detail form manually you will know the settings and would be able to add more tables to it easily. To demonstrate this example, I am using Oracle Apex 19.2.
Steps to Create a Master-Detail Form/Interactive Grid Manually in Oracle Apex
1. Create a blank page in Oracle Apex as shown in the below image:
Give a name to your master-detail page and set the page mode and breadcrumb according to your needs and then click on the Next button. Then on the next step, select the navigation menu and click on Next then Finish.
2. You have created a blank page. Now add an Interactive Grid to it. I am using the
EMPLOYEES table to create the interactive grid and this table has the primary key
EMPLOYEE_ID. To create an interactive grid region, do the right-click on the Content Body and select Create Region option. Then set the following properties (also shown in the image below):
- Title: Employee Master
- Type: Interactive Grid
- Source Type: Table
- Table Name:
3. Then click on the Attributes node and enable the edit mode for the interactive grid as shown in the below image:
4. Now you must specify the Primary Key for the interactive grid so that you can add detail tables to the page and can link them with it. For this
EMPLOYEES table, the Primary Key is
EMPLOYEES_ID. To specify the primary key, open the Columns node and then select the column
EMPLOYEE_ID and switch on the Primary Key button in the source section, as shown in the below image:
Note: If you have multiple primary key columns for the master table, then repeat the above step (4) for every column.
5. Now I have one more table
EMPLOYEE_DOCS, which I will add as the detail table. To do this, do the right-click on the Content Body and select the Create Region option and then set the following properties shown in the below image:
- Title: Employee Docs
- Type: Interactive Grid
- Source > Table Name:
- Include ROWID Column: Yes
- Master-Detail > Master Region: Employee Master (Select the master region)
Note: In the first master table (
EMPLOYEES for the region Employee Master), we define the Primary Key as
EMPLOYEE_ID and didn’t include the
ROWID column, which is correct. But for the detail table, you do not need to specify the Primary Key column, just include the
ROWID column and it will be set as Primary Key column so that insert, update and delete can happen on the behalf of
ROWID column for this detail table. But now, you need to link the column
EMPLOYEE_DOCS table to the master table column
EMPLOYEES table for the master-detail relationship. To do that follow this step:
6. Enable the edit mode for the Employee Docs region. To do this click on the Attributes node and then click on the Enabled button (as shown in the 3rd step).
7. Now link the
EMPLOYEE_DOCS table column
EMPLOYEE_ID with the
EMPLOYEES table column
EMPLOYEE_ID. To do this, open the columns node of Employee Docs region and click on the
EMPLOYEE_ID column and set the following settings:
- Type: Hidden (this column should be hidden as it is the detail column)
- Master-Detail > Master Column:
Note: If you have multiple primary key columns in the master table, then repeat the 7th step for every column in the detail table.
Now if you want to add more tables to this form, you can repeat the steps from 5th to 7th.
To learn more about the master-detail form in Oracle Apex 19.1, check the Oracle Documentation.