The "out-of-date" issue of calculated fields
"Calculated fields" is one of many awesome features of AppGini. By using calculated fields you can calculate or concat values based on other (editable) fields.
For example in the following screenshot of a "Business Partner" detail view there are three columns Name (1)
, Name (2)
and Abbreviation
.
The 4th field label
(Bezeichnung) is a calculated field which concats values of the other three fields like this:
name1
name2
[ abbreviation
]
Now, when editing one of the three input fields the calculated field label
still shows the same data - which might be out of date now:
The label
field itself will be updated on save, that's fine. But right now it does not match.
Preferred behavior
I would like to indicate that the change could have an influence on the calculated field. So I have written a change-handler which highlights the calculated field on change.
// file: hooks/partners-dv.js AppGiniDetailView.getInstance().getField("label").highlightOnChange();
Result
As you can see there is a wavy underline in orange (similar to spelling-mistake indicators). Well, still the value does not match. But my customer can see that there may be a change on save.
Showcase
Alternative: fade out / hide
As an alternative to highlighting, I can also fade out the calculated field...
AppGiniDetailView.getInstance().getField("label").fadeOutOnChange();
...or hide it
AppGiniDetailView.getInstance().getField("label").hideOnChange();
AppGini Helper Features
highlightOnchange
feature
should be available by the end of 2020hideOnChange
feature
should be available by the end of 2020fadeOutOnChange
feature
should be available by the end of 2020
For single fields
new AppGiniField("field").highlightOnChange();
should be available by the end of 2020
Those features will work on multiple fields, too:
new AppGiniFields("field1", "field2", "...").highlightOnChange();
should be available by the end of 2020
PS: SQL of calculated field
SELECT trim( concat_ws(" ", name, name2, CASE WHEN abbreviation IS NOT NULL THEN concat_ws(' ', '[', abbreviation , ']') ELSE null END ) ) FROM partners WHERE id = '%ID%'