How to change the column name in smarttable in sap ui5 with annotation file
During the last week, I was trying to consume an OData service via SmartTable that I created over CDSs. My OData and SmartTable were ready. However, my Column names in the table came in a different names from CDS. I needed to customize them and give the Label Texts I wanted. It was shared on the forums that it was made over the Annotation file, but I realized that there was no screenshots and details of how it was done, so I decided to write this Blog.
First of all, I assume that our SmartTable is being displayed:
Our aim is to change the Header Lebel Texts here.
We need to have an annotation file. There is no annotation file in a project that you created on Webide.
We are creating a new folder, we call it annotations.
We name our Annotation file and choose our OData connection.
Click on Select Target and select the relevant EntityType and Property.
We add a new annotation by pressing the Plus sign at the end of the Local Annotation line. We add DataFieldDefault property.
We add the DataField by pressing the plus sign in the DataFieldDefault line.
We select the relevant Column from the Value Property section and press the plus sign.
We add a Label to the relevant field.
We write the String we want to use as a Label, either from the i118n File or manually.
We save and refresh our project. We see that the name of our related field has changed.
If you want, you can change the names of all fields in a short time by duplicating the code blocks created for the field fields whose names you know from the code editor.
Thank you for taking the time to read my blog.