9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Ontoor Blogs
Home / Posts / 2 ways to get total sum of Interactive Grid Column Oracle APEX
2 ways to get total sum of Interactive Grid
Column Oracle APEX
Vikas Pandey Feb 6, 2021
2 min read
Vikas Pandey APEX APEX
PLSQL SQL
How to Calculate total sum of interactive grid column into
page item in oracle APEX.
Most of the time, this question was asked by my friends and colleagues that “How to
Calculate total sum of interactive grid column into page item in oracle APEX” then i got
solution in two ways.
Solution 1.
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 1/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
1. Need to create an editable interactive grid report using emp table and Page item
Ontoor Blogs
Px_ITEM.
2. Copy and Paste below code in “Function and Global Variable Declaration”.
(function($) {
function update(model) {
var salKey = model.getFieldKey("SAL"),
total = 0;
console.log(">> starting sum SAL column")
model.forEach(function(record, index, id) {
var sal = parseFloat(record[salKey]),
meta = model.getRecordMetadata(id);
if (!isNaN(sal) && !meta.deleted && !meta.agg) {
total += sal;
});
console.log(">> setting sum SAL column to " + total)
$s("P23_TOTAL", total);
$(function() {
$("#emp").on("interactivegridviewmodelcreate", function(event, ui) {
var sid,
model = ui.model;
if ( ui.viewId === "grid" ) {
sid = model.subscribe( {
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 2/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
onChange: function(type, change) {
Ontoor Blogs console.log(">> model changed ", type, change);
if ( type === "set" ) {
if (change.field === "SAL" ) {
update( model );
} else if (type !== "move" && type !== "metaChange") {
update( model );
},
progressView: $("#P23_TOTAL")
} );
update( model );
model.fetchAll(function() {});
});
});
})(apex.jQuery);
Note: Defile region static id- “emp”.
Solution 2:
1. Now create a dynamic action on the SAL column of IG for change event.
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 3/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Ontoor Blogs
2. Create a true action as Set Value. Set the type PL/SQL expression as :SAL and submit
the SAL.
3. Create another true action to execute JavaScript code and add the following code:
var model = apex.region("ONTOOR").widget().interactiveGrid("getViews", "grid").mo
var n_amt, n_totamt = 0;
col_amt = model.getFieldKey("SAL");
model.forEach(function(igrow) {
n_amt = parseInt(igrow[col_amt], 10);
if (!isNaN(n_amt)) {
n_totamt += n_amt;
});
apex.item("P23_TOTAL").setValue(n_totamt);
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 4/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Ontoor Blogs
Demo
You might Like :
3 Ways to Open Inline Model Dialog Using JQuery In Oracle APEX
How to Create Dynamic Navigation Menu in Oracle APEX
Preserve Checkbox state while Paginating in Interactive/Classic Report Oracle APEX
Add Tooltip on Side Navigation Menu Oracle
< APEX Camera Extension (ACE) >
APEX
Related Posts
Refresh region of base page when closing modal dialog | Oracle APEX
3 Ways to Unselect Default Checkbox in Interactive Grid Oracle APEX
APEX page types | Universal Theme
Smooth row view Interactive report Oracle APEX
Handle trigger Mutating Error
We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
0 Comments
- powered by
utteranc.es
Write Preview
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 5/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Ontoor Blogs
Sign in to comment
Styling with Markdown is supported
Sign in with GitHub
Vikas Pandey
APEX,PLSQL
Ontoor
India
About
Featured Posts
APEX_JSON.WRITE_RAW
First Day of the YEAR : ROUND (DATE)
Download files in APEX
Generate DDL of any object in ORACLE
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 6/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Upload Multiple Files in Oracle APEX
Ontoor Blogs
Recent Posts
APEX_JSON.WRITE_RAW
First Day of the YEAR : ROUND (DATE)
Download files in APEX
Generate DDL of any object in ORACLE
Upload Multiple Files in Oracle APEX
How to upload multiple files in APEX
ORACLE INVISIBLE Column can be used for column ordering
How to find ORACLE locked Objects?
APEX APIs
Oracle Application Express JavaScript API Reference
Article publishers
Ashish Sahay 121 Vikas Pandey 53 Hugo Authors 6 Anuj Kumar 1
Categories
APEX 109 ORACLE 27 PLSQL 15 PLUGINS 10 DBA 6 JavaScript 5
GitHub 4 SQL 4 BLOGGER 3 ORDS 3 APEX_JSON 2 CSS 1
SCRUM 1
APEX Plugins
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 7/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Dynamic Action 7 Region 3
Ontoor Blogs
APEX Plugins
Dynamic Action 7 Region 3
Short Codes
APEX 7 SQL 6 JAVASCRIPT 2 PLSQL 2 FILE_UPLOAD 1
Tags
APEX 116 PLSQL 111 SQL 106 ORACLE 33 PLUGINS 25 TEMPLATES 14
Dynamic Action 10 OntoorPlugins 10 JavaScript 9 API 8 DBA 8
Classic Report 5 APEX_JSON 4 CSS 4 MARKDOWN 4 Universal Theme 4
APEX 21 3 BLOGGER 3 GitHub 3 ORDS 3 PLUGIN 3 UI 3
APEX+CSS 2 apex.server 2 APEX_COLLECTIONS 2 APEX_DATA_PASER 2
APEX_WEB_SERVICE 2 BOILERPLATES 2 Coalesce 2 DBMS_LOB 2
DOWNLOAD 2 GOOGLE 2 HTML 2 Interactive Grid 2 Interactive Report 2
ITEM 2 JSON_TABLE 2 RDS 2 TEMPLATE 2 THEMES 2 UNESCAPE 2
WRITE_RAW 2 AGILE 1 APEX 20.1 1 APEX and CSS 1 APEX COLLECTION 1
APEX_DATA_PARSER APEX_LANG APEX_SESSION apex_util
1 1 1 1
APEX_ZIP 1 ATTACHMENT 1 BLOB 1 Cascade 1 CHECKSUM 1 CLOB 1
COLUMN_ORDERING 1 CUSTOM 1 DBMS_METADATA 1 DDL 1 Deleted 1
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 8/9
9/25/21, 5:15 PM 2 ways to get total sum of Interactive Grid Column Oracle APEX - Ontoor Blogs
Directory 1 Emoji 1 FILE_BROWSE 1 FILE_UPLOAD 1 FILES 1
Ontoor Blogs
Function 1 IG 1 Instagram 1 Interactive Active 1 INVISIBLE 1 IR 1
JQUERY 1 JS_API 1 LOV 1 Math 1 MEGA MENU 1 MULTIPLE_FILE 1
Navigation 1 New line 1 NULL 1 NULLIF 1 NVL 1 NVL2 1
OBJECT 1 OBJECT_LOCK 1 ORA 1 ORACLE_TO_XML 1 PAGE 1
PAGE GROUP 1 Page Zero 1 PIPELINE 1 POP UP LOV 1 Privacy 1
REPLACE 1 RSS 1 SCRUM 1 SELECT LIST 1 Special Character 1
Sticky 1
Copyright © 2021 Ontoor Solutions. All Rights Reserved.
https://blogs.ontoorsolutions.com/post/2_ways_to_dynamicly_sum_grid_column/ 9/9