In this Oracle Apex tutorial, I will teach you how to add an Interactive Grid into a Form manually to make it behave like master-detail form.
I have an existing form on the Department table which is having two fields, DEPTNO
and DNAME
. The requirement is to add a detail section below the form to show all employees under the current department, and the user can add/edit employees under that department.
So, in this case, we should add an Interactive Grid into the form. Follow these steps:
Add an Interactive Grid into a Form Manually in Oracle Apex
- Open the form in Oracle Apex designer in which you want to add an Interactive grid. To demonstrate this, I am using the Department form, which is being called by the Department Report.
- Then right-click on the Content Body and click on the Create Region and set the following properties highlighted in the image below:
- I added the following query into the above SQL Query section:
Select ROWID, empno as employee_no, ename as employee_name, hiredate, deptno as dept, sal as salary from emp where deptno = :p5_deptno
You can see above that I added the P5_DEPTNO
in the Page Items to Submit because I am using this item in the query. So you should add all the items you are using in the query to Page Items to Submit.
- It is better to use
ROWID
as Primary Key instead of actual Primary Keys for the Forms and Reports in Oracle Apex because it is faster to fetch and update records using theROWID
for faster performance, also helps to assign default values to the columns we are linking to the master table. In this example, we are linkingDEPTNO
from theEMP
table to theDEPT
table. So now click on theDEPT
field in the Employees region and set the following properties:
The above properties I have set because when the user clicks on the Add Row button in the Interactive GRID, it will take the default DEPTNO
from the Master table DEPT.
- Now click on the Attribute section of this Interactive Grid and set the properties shown below:
Now when you open the Department form from the Department Report for a specific department number, you will have the following output: