🚀 Dynamic Default Value for New Interactive Grid Rows in Oracle APEX
🚩Introduction
In modern Oracle APEX applications, it is important to make data entry quick and accurate for users. A useful feature is setting the default value of an Interactive Grid column dynamically based on a page item value.
For example, in a master-detail form, the master value should automatically be added to the Interactive Grid column whenever a new detail row is created. By default, an Interactive Grid column takes its value from a page item only during page rendering. With a little JavaScript, we can make the column always pick up the latest page item value whenever a new row is added. This keeps new rows accurate, saves time, and makes the application easier to use.
📑 Why This Approach Is Needed
In Oracle APEX, the default value of an Interactive Grid column is usually fixed during page load. So when a user changes the page item later, the new value does not get applied to the column when a new row is created. This can cause wrong or outdated values to appear.
Setting the column default value dynamically becomes important when:
- Users change the page item value after the page has loaded
New rows should always use the latest page item value
Data needs to stay accurate and consistent
Manual correction of column values should be avoided
A smooth and reliable user experience is important
This approach helps users to add new rows with the correct value every time, reduces errors, and keeps the data entry process simple and accurate in Oracle APEX.
👉 Use Case: Dynamically Setting the Default Value for an IG Column
Step 1:
SELECT EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
FROM EMP;
Step 2:
Step 3:
Step 4:
Step 5:
Now Click on the page and go to the Function and Global Variable Declaration section and copy paste the below javascript function.
--- Function and Global Variable Declaration ---
function setIGColumnValue() {
var region = apex.region("RG_EMP"); // IG Static ID
var view = region.widget().interactiveGrid("getViews", "grid");
var model = view.model;
var record = view.getSelectedRecords();
if (record) {
model.setValue(
record[0],
"JOB", // Column Name
$v("P14_DEFAULT_VALUE") // Page Item Name
);
}
}









The Row Initialization step is a particularly useful part of this approach. Updating the selected row when the page item changes is one thing, but making sure newly added rows pick up the latest value is where this solution becomes much more practical. The combination of Dynamic Actions and setIGColumnValue() provides a simple way to keep Interactive Grid data consistent without relying on manual updates. Oracle Forms to Apex Migration
ReplyDelete