Check out this sample project:
- having caption
- is not readonly here (important) ...
- but unique ...
- and required ...
Same settings have been applied to field
Now let's create our first sample record. See how fields Identifier and Full name are reaonly now and will be auto-filled when entering data into First name and Last name fields:
After insert, we now have that new record including the calculated fields:
// file: hooks/contacts-dv.js // get a handle to detail view var dv = AppGiniHelper.dv; // calculate field "full_name" // concat values of last_name, first_name, middle_names // default separator: ", " dv.getField("full_name").setFunction(["last_name", "first_name", "middle_names"]);
Serverside check for uniqueness
Let's try to create another record and let's make use of AppGini's automatic check for uniqueness.
For this it is important to check the unique flag in your project:
Please note that we already have created a record before, having
full_name = "Setzer, Jan".
After automatically evaluation of the
full_name field, AppGini will check the value against the database on serverside and mark the field.
Please also note that the save-button (insert-button) will be disabled automatically.
The combination of AppGini's serverside check of unique constraints and AppGini Helper's clientside auto-calculation is very powerful, if you ask me.
Different separator (“glue”)
If you need a different separator, pass it as 2nd parameter:
// custom separator: " / " dv.getField("full_name").setFunction(["last_name", "first_name", "middle_names"], " / ");
Next: More complex calculations
In this example I have just concatenated values of existing fields as strings. But there is much more in next lesson. See page 2.