Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 545 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 442 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
IG compute values

I have a IG with three columns, Var1; Var2 and Var3
I would like to compute values of Var1 when the values are changing.
Finaly it should be fire a alert when the sum of Var1 is greater then 100 (because it is percent).
I did
var model = apex.region("IG1").widget().interactiveGrid("getViews","grid").model;
var var1 = model.getFieldKey("VAR1");
var sum;
var total = 0;
model.forEach(function(igrow) {
sum = parseInt(igrow[var1],10);
total += sum;
})
alert("Wert ist :" + total );
It works, BUT
But it is fired
on the IG Column and if I change the one value the computed value is the old an not the new value, so it ignores the new inputed value.
Example
VAR1
VAR1 Value 1
VAR1 Value 2
VAR1 Value 3
SUM = 6
If I Change one of the values lets assume the first from 1 to 5 uit should be 10 but it shows still 6.
If i change it the next time it shows 10 wich is correct for the prvious values .
Any Ideas
Thank you
Answers
-
Hello,
See IG Cookbook Page 5 Application it may helps.
-
Again ;-)
APEX 21.2.0
A IG with 3 Fields (var1; var2; var3).
On Event Change VAR1
True Action
And Execuote JavaScriptCode
Code is:
var model = apex.region("IG1").widget().interactiveGrid("getViews","grid").model;
var var1 = model.getFieldKey("VAR1");
var sum;
var1 = 0;
var total = 0;
console.log("Var1=" + var1);
console.log("total=" + total);
model.forEach(function(igrow) {
sum = parseInt(igrow[var1],10);
total += sum;
//alert ("Var1xxx = " + igrow[var1]);
// console.log(Number(igrow[var1]));
// console.log(sum);
console.log("Var1 = " +igrow[var1]);
console.log("Total = " +total);
})
//alert("Wert ist :" + total );
If I execute it:
If I change one Value of VAR1:
If I change that value again;
It takes always the value from the last action. but not from the current action.
Any Ideas ?
Thank you
-
Any Ideas ?
If you downlead the IG Cookbook app above you will get the idea :) any way try this In Function and Global Variable Declaration :
NOTE: Change
[IG_STATIC_ID]
to your IG Static Id e.g."emp" :(function($) { function update(model) { var var1Key = model.getFieldKey("VAR1"), total = 0; model.forEach(function(record, index, id) { var var1 = parseFloat(record[var1Key]), meta = model.getRecordMetadata(id); if (!isNaN(var1) && !meta.deleted && !meta.agg) { total += var1; } }); console.log(">> setting sum VAR1 column to " + total); } $(function() { $("#[IG_STATIC_ID]").on("interactivegridviewmodelcreate", function(event, ui) { var sid, model = ui.model; if ( ui.viewId === "grid" ) { sid = model.subscribe( { onChange: function(type, change) { if ( type === "set" ) { if (change.field === "VAR1" ) { update( model ); } } else if (type !== "move" && type !== "metaChange") { update( model ); } } } ); update( model ); model.fetchAll(function() {}); } }); }); })(apex.jQuery);