I have been breaking my brain on this one :
I have a form with a tabbed form on it. (parent-child(s))
I need a calculation on the parent form to show the total sum of a column in the childs.
When I use the same relation as on the tabbed form, the calculation is
not correct when the users does a find/search in the child form.
Because if the users finds a subset of the related child records, then the calulation
is only done on this subset. Matematically correct, but not what I want.
I always want to show the total of all child record regardless if they are shown or not.
When I use a different relation ( same definition, other name), the calculation stays
correct even when the user does a find/search on the child records.
That makes sense, because the other name results in a different foundset.
But then I have another problem : when I create new child records, they are not part of
the "other" foundset, so the calculation does not get updated.
Has anyone come across this and found a solution ?
My current way around this is to use the use the "different relation name" and do a databaseManager.recalculate on the parent when the childs are saved.
That works, but it does not seem logical...
My calculation on the same relation as the tabbed form is :
- Code: Select all
function calc_s() {
var _tot = 0
if (par1_to_chi1) {
for (var i = 1; i <= par1_to_chi1.getSize(); i++) {
_tot = _tot + par1_to_chi1.getRecord(i).aantal
}
}
return _tot
}
My calculation on a different relation name is :
- Code: Select all
function calc1() {
var _tot = 0
if (full_par1_to_chi1) {
for (var i = 1; i <= full_par1_to_chi1.getSize(); i++) {
_tot = _tot + full_par1_to_chi1.getRecord(i).aantal
}
}
return _tot
}