How to add Text Annotation in SAP UI5 Table

The CDS View Text Annotation @ObjectModel.text.element is used to set the sap:text Inline Annotation in the metadata. The CDS View Text Annotation looks like below

@ObjectModel.text.element: ['Name']
Id as CustomerID

The above CDS View Text Annotation will generate the below Inline Annotation in Metadata. It is the human readable text for the value of this Property ‘Id’

                        <Property Name="Id"
                            Type="Edm.String"
                            Nullable="false"
                            MaxLength="10"
                            sap:visible="true"
                            sap:label="Customer ID"
                            sap:creatable="false"
                            sap:text="Name" />
                        <Property Name="FC"
                            Type="Edm.Byte"
                            sap:label="Field control" />
                        <Property Name="Name"
                            Type="Edm.String"
                            MaxLength="70"
                            sap:field-control="FC"
                            sap:creatable="false"
                            sap:updatable="true"
                            sap:label="Customer Name" />

The above Inline metadata Annotation for the Property Id will render the SAP UI5 Smart Table with Name and Id together for the Column ‘Id’.

Text Annotation used in Smart Table

As seen in the above picture, the Column ‘Customer ID’ consists of both the Name and Id. The default textArrangement: #TEXT_FIRST will be used, although no TextArrangement is explicitly mentioned.