cancel
Showing results for 
Search instead for 
Did you mean: 

OData v4 binding to SAPUI5 view table / SAP CAP

Erkan
Explorer

Dear experts,

I am using SAP CAP model to develop an application with Business Application Studio. I have CDS defined and data is being published as oDatav4 format.

This is my manifest.json file. Also default model is defined

    "dataSources": {
      "mainService": {
        "uri": "/srv-api/rooms/",
        "type": "OData",
        "settings": {
          "odataVersion": "4.0"
        }
      }
    }

.
.
.

    "models": {
     
      "": {
        "dataSource": "mainService",
        "preload": true,
        "settings": {
          "operationMode": "Server",
          "groupId": "$direct",
          "synchronizationMode": "None",
          "autoExpandSelect": true
        }
      }
    },

This is also my CDS odata

and here is my view.

                <Table
                    id="productsTable"
                    inset="false"
                    items="{
                        path: '/Rooms' 
                        
                    }"
                    class="sapFDynamicPageAlignContent"
                    width="auto">
                    <columns>
                        <Column width="12em">
                            <Text text="Office Area"/>
                        </Column>
                        <Column hAlign="End">
                            <Text text="Availability"/>
                        </Column>
                    </columns>
                    <items>
                        <ColumnListItem type="Navigation" press=".onListItemPress">
                            <cells>
                                <ObjectIdentifier title="{roomName}" text="{roomCountry} - {roomCity}"/>
                                <ObjectNumber
                                    unit="{roomSeatNumber}"/>
                            </cells>
                        </ColumnListItem>
                    </items>
                </Table>

Could you tell me where I am making a mistake while binding data in XML view? There is no data being transferred to view with this method. I am sure I am making some newbie mistake somewhere but still I'm not able to figure out.

I know that oDatav4 is not supporting direct access and i dont want to use jQuery/ajax get method to bind my data to view.

Thank you in advance.

Regards,

Erkan

Accepted Solutions (1)

Accepted Solutions (1)

Erkan
Explorer

hi, I figured out that I have to bind oData service in my controller too.

Also there is no error log, basically it was not bound through manifest.json only.

Followed oData v4 documentation for solution:

https://sapui5.hana.ondemand.com/#/topic/5de13cf4dd1f4a3480f7e2eaaee3f5b8

minjie_lao
Product and Topic Expert
Product and Topic Expert
0 Kudos

Instead of binding from controller, did you try to use 'rows' attribute. The data source should be automatically bind to the view.

rows="{
                        path: '/Rooms' 
                        
                    }"

Answers (1)

Answers (1)

WouterLemaire
Active Contributor

Looks fine on first sight. Do you see any error in the console log? Do you see the request for Rooms in the network trace?

Maybe this blog post and demo app can help you https://blogs.sap.com/2020/11/06/ui5ers-buzz-56-new-full-stack-ui5-sample-app-featuring-cap-odata-v4...