Customising Display Names
Introduction
A display name is a client-side concept used to create a human readable name for an entity.
Customising an Entities Label
An entities display name is automatically set to the name it was given on the entity diagram. However, if you want to customise it in the target application, this will then modify it in the clientside model file. In this case, if I had an entity called Category
then the model file will be in clientside/src/Models/Entities/CategoryEntity.tsx
.
In this file there will be an @entity
decorator wrapped in a protected region.
// % protected region % [Customise your entity metadata here] off begin
@entity('CategoryEntity', 'Category')
// % protected region % [Customise your entity metadata here] end
Enabling the protected region and changing the second argument, will alter the label used in the application. It is important to leave the first argument unchanged as that property does not affect the UI.
Customising an Entities Display Name
The display name is the string representation of the instance of an entity. By default this is set to the id of an object. Changing this will alter all places where objects are displayed as strings, eg. setting references in the administration backend.
To change the value displayed, navigate to the same client-side model file as above and find the following code block (it should be near the bottom of the file).
/**
* Returns the string representation of this entity to display on the UI.
*/
public getDisplayName() {
// % protected region % [Customise the display name for this entity] off begin
return this.id;
// % protected region % [Customise the display name for this entity] end
}
This protected region can be enabled and the default return this.id
can be replaced with some custom logic.
Was this article helpful?