Calculated fields are fields that do not have their own values, but the values are calculated from the other fields of the same record. It is easiest to implement them in Model. For that:
- add config:
persist:false - implement
convertfunction
In this example we concatenate First Name, space and Last Name to create a Full Name of the person.
Model Configuration
convert receives "value to convert"(v) and record as arguments. In this case we ignore the passed value entirely, because it is not needed to create the full name.
Now we have only one little problem to solve: If you update first name or last name, for example in an editable grid, the full name is not updated. It is because convert method is called only if full name needs update.
So one more override:
Here we override the default set method of the model. The override forces update of fullname always when any field is updated.



2 comments
Comments are closed on archived posts.