πΉ About
This step-by-step blog explains how to dynamically calculate and display the total (SUM) of a column in an Editable Interactive Grid (IG) using Oracle APEX and JavaScript.
Instead of relying on the default footer aggregation, we will:
β Hide the IG footer
β Create a custom display region
β Calculate total dynamically on change
β Show real-time updates
π οΈ Tools and Technologies
- Oracle APEX
- JavaScript
π Step-by-Step Implementation
β Step 1: Create Editable Interactive Grid
Create an Editable Interactive Grid based on the EMP table.
β Step 2: Assign Static ID
Go to your IG region β Advanced β Static ID
emp_igβ Step 3: Hide Footer Using Initialization Code
Go to:
IG Region β Attributes β Initialization JavaScript Function
Add:
function ( config ) {
config.defaultGridViewOptions = { footer: false }; // Hides Footer
return config;
}π‘ This removes the default total row so we can build a custom one.
β Step 4: Create Display Region
Create a Static Content Region:
Display Total
Display TotalSet Template Options:
- β Remove Body Padding
- β Header β Hidden but Accessible
- β Item Spacing β Slim
- β Top Margin β None
- β Bottom Margin β None
β Step 5: Create Page Item
Create a Display Only Item:
PXX_TOTAL_SALSet Properties:
- Send on Page Submit β Off
- Column β 9
- Warn on Unsaved Changes β Ignore
β Step 6: Create Dynamic Action (On SAL Change)
πΉ Event Details
- Column β SAL
- Event β Change
πΉ True Action 1: Set Value
- Set Type β PL/SQL Expression
- Expression β
:SAL- Items to Submit β SAL
- Affected Item β PXX_TOTAL_SAL
πΉ True Action 2: Execute JavaScript
var model = apex.region("emp_ig").widget().interactiveGrid("getViews", "grid").model;
var n_sal, n_total = 0;
var col_sal = model.getFieldKey("SAL");
// Loop through IG rows
model.forEach(function(igrow) {
n_sal = parseInt(igrow[col_sal], 10);
if (!isNaN(n_sal)) {
n_total += n_sal;
}
});
console.log(n_total);
// Set value to page item
$s('PXX_TOTAL_SAL', n_total);πΉ Client-side Condition
- Type β Item/Column is not null
- Column β SAL
β Step 7: Dynamic Action on Page Load
Create another Dynamic Action:
πΉ Event
- Event β Page Load
πΉ True Action: Execute JavaScript
Use the same code:
var model = apex.region("emp_ig").widget().interactiveGrid("getViews", "grid").model;
var n_sal, n_total = 0;
var col_sal = model.getFieldKey("SAL");
model.forEach(function(igrow) {
n_sal = parseInt(igrow[col_sal], 10);
if (!isNaN(n_sal)) {
n_total += n_sal;
}
});
$s('PXX_TOTAL_SAL', n_total);π― Final Output
β Real-time total calculation
β Updates when SAL column changes
β Clean UI (no footer clutter)
β Fully dynamic without page refresh
π‘ Why This Approach?
Instead of using default IG aggregation:
β Limited customization
β Footer clutter
We use:
β JavaScript model API
β Custom UI region
β Real-time updates
π Pro Tips
β Use parseFloat() if dealing with decimals
β Add formatting using toLocaleString()
β Extend for multiple columns (Bonus)
π₯ Use Cases
- Salary calculations
- Invoice totals
- Order summaries
- Financial dashboards
π Conclusion
This approach gives you full control over Interactive Grid calculations and improves user experience with real-time updates and clean UI.
Love coding? Me too! Letβs keep in touch β subscribe to my website for regular chats on Oracle APEX, PL/SQL,SQL JavaScript, and CSS.



