cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP - Smart Table OData V2 Annotation, cannot set fields to readonly

daniel_endres
Explorer
2,726

Is it possible to enable edit mode for only particular properties on an Smarttable which is served by a CAP (via the cds-odata-v2-adapter-proxy).

I am able to bind the SmartTable and show the rows and also the edit button works, but it enables all properties.

I tried various annotations but still all fields are enabled for edit.

annotate TestEndpoint.Participants {
lastName @sap.updatable:false ;
lastName @Common.FieldControl: 1; //#ReadOnly;
firstName @sap.updatable:false @readonly;
lastName @sap.creatable:false ;
lastName @sap.label:'Last name Dummy' ;
ID @sap.updatable:false ;
}

The V2 Metadata Annotations look ok for me.

<EntityType Name="Participants"><Key><PropertyRef Name="ID"/></Key><Property Name="ID" Type="Edm.Guid" Nullable="false" sap:updatable="false"/><Property Name="lastName" Type="Edm.String" MaxLength="80" sap:updatable="false" sap:creatable="false" sap:label="Last name Dummy"/><Property Name="firstName" Type="Edm.String" MaxLength="80" sap:updatable="false"/><Property Name="score" Type="Edm.Int32"/></EntityType>

All Fields are editable after hitting the edit toggle, somehow it ignores the readonly definitions.

on the UI Side I followed the example from the UI5 Docs.

<smartTable:SmartTable editTogglable="true" 
     entitySet="Participants" 
     app:useSmartToggle="true" 
     showRowCount="true" 
     enableAutoBinding="true" 
     class="sapUiResponsiveContentPadding" 
     tableType="Table" 
     enableAutoColumnWidth="true"> 
</smartTable:SmartTable>

I created a dedicated Node CAP App which has that problem.

Link to Repo

View Entire Topic
hasanciftci
Explorer

Hello,

You need to add app:useSmartField="true" attribute to your smart table and annotate the fields with @Common.FieldControl: #ReadOnly. It doesn't work without app:useSmartField="true" attribute.

 

 
XML View
hasanciftci_0-1710536525139.png
 
Smart Table
hasanciftci_2-1710536595720.png

 

Annotations
hasanciftci_1-1710536547069.png

 

Result

hasanciftci_3-1710536615068.png