Hi,
Under APEX 24.1 I have an interactive grid. I want to calculate the fureations (in hours) between 2 dates in the IG. I was inspired by this post from @dasshini-ravi :
https://forums.oracle.com/ords/apexds/post/trying-to-calculate-dynamically-the-sum-of-a-colum-in-an-in-7064
I have done this:
(function($) {
function update(model) {
var salKey = model.getFieldKey("DUREE");
console.log(">> starting sum DUREE column")
model.forEach(function(record, index, id) {
var sal = parseFloat(record[salKey]),
meta = model.getRecordMetadata(id);
if (!isNaN(sal) && !meta.deleted && !meta.agg) {
DUREE = HEURE_FIN - HEURE_DEBUT;
}
});
}
$(function() {
$("#EMP").on("interactivegridviewmodelcreate", function(event, ui) {
var sid,
model = ui.model;
if ( ui.viewId === "grid" ) {
sid = model.subscribe( {
onChange: function(type, change) {
console.log(">> model changed ", type, change);
if ( type === "set" ) {
if (change.field === "HEURE_DEBUT" ) {
update( model );
}
} else if (type !== "move" && type !== "metaChange") {
update( model );
}
},
} );
update( model );
model.fetchAll(function() {});
}
});
});
})(apex.jQuery);
The calculation is made by substracting HEURE_FIN from HEURE_DEBUT: DUREE = HEURE_FIN - HEURE_DEBUT; and stotinh this value in the field DUREE of the IG grid.
It is not working, could you help me find why?
Best regards.