Hello,
APEX Version: 24.1.6
I have an interactive grid region based on a function body returning a sql query.
I have 1 editable field ‘LANG_LETTER’, it can be NL, FR and EN. I have put a select list on it with static values.
I can change the value of this field. All works well.
Now the user wants that when he changes that field for a certain row, all other rows with the same value in columnA, must be updated with this new value.
I was able to get some Javascript code to make this change. But I always struggle with the fact that I do not see the changes to the other rows until I select them.
What should I to to see the changes directly, without the need to go to the record itself?
Javascript code used:
var igId = "ig_exams"; // Replace with your Static ID
var model = apex.region(igId).widget().interactiveGrid("getViews", "grid").model;
if (window.igLangSub) {
window.igLangSub.unsubscribe();
}
window.igLangSub = model.subscribe({
onChange: function(changeType, change, id) {
// 1. Only react to 'set' on LANG_ID
if (changeType !== "set" || change.field !== "LANG_LETTER") return;
// 2. Prevent infinite loops
if (this._isUpdating) return;
this._isUpdating = true;
var changedRecord = change.record;
var newLang = model.getValue(changedRecord, "LANG_LETTER");
var targetFkId = model.getValue(changedRecord, "COLUMNA");
// 3. Loop through all records and update matching FKs
model.forEach(function(record) {
var currentFkId = model.getValue(record, "COLUMNA");
// Only update if the FK matches and the value is actually different
if (currentFkId === targetFkId && model.getValue(record, "LANG_LETTER") !== newLang) {
model.setValue(record, "LANG_LETTER", newLang);
}
});
this._isUpdating = false;
}
});
Thx for your ideas.
Filip