Search code examples
sapui5

Cant seem to connect oData table to a smart table


I was trying to connect an oData table to a smart table in my web ide using the following code. I have seen the metadata of my oData and the entity set I want to access is trainingPlan. PLANID and COURSEID are 2 columns in the table I am accessing. In the result screen just the empty toolbar is coming and 'no data' is written beneath it. The table is accessible as I tried to display using normal table and the data is showing.

#App.view.xml
<core:View xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
xmlns:smartTable="sap.ui.comp.smarttable" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1" controllerName="Workspace.controller.App" height="100%">
<smartFilterBar:SmartFilterBar id="smartFilterBar" entitySet="trainingPlan" persistencyKey="SmartFilter_Explored" enableBasicSearch="true"  >
    <smartFilterBar:controlConfiguration>
        <smartFilterBar:ControlConfiguration key="PLANID"></smartFilterBar:ControlConfiguration>
        <smartFilterBar:ControlConfiguration key="COURSEID"></smartFilterBar:ControlConfiguration>
    </smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<smartTable:SmartTable entitySet="trainingPlan" initiallyVisibleFields="PLANID"  smartFilterId="smartFilterBar" tableType="ResponsiveTable" useExportToExcel="true"
    useVariantManagement="false" useTablePersonalisation="true" header="Line Items" showRowCount="true" tableBindingPath="{TEST>/trainingPlan}"
    persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true" demandPopin="true" class="sapUiResponsiveContentPadding"
    />
</core:View>

#metadata.xml
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" 
Version="1.0">
<edmx:DataServices 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
m:DataServiceVersion="2.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
xmlns="http://schemas.microsoft.com/ado/2008/09/edm" 
Namespace="demo.services.demo">
<<EntityType Name="trainingPlanType">
<Key>
<PropertyRef Name="PLANID"/>
<PropertyRef Name="COURSEID"/>
</Key>
<Property Name="PLANID" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSEID" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSENAME" Type="Edm.String" Nullable="false" 
MaxLength="255"/>
<Property Name="STARTDATE" Type="Edm.DateTime" Nullable="false"/>
<Property Name="AVAILSEAT" Type="Edm.Int32" Nullable="false"/>
<Property Name="TOTALSEATS" Type="Edm.Int32" Nullable="false"/>
<Property Name="ROOMNO" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSEDURATION" Type="Edm.String" MaxLength="255"/>
</EntityType>
<EntityContainer Name="demo" m:IsDefaultEntityContainer="true">
<EntitySet Name="trainingPlan" 
EntityType="demo.services.demo.trainingPlanType"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

Solution

  • I assume you used a model named "TEST".

    If you obtain the OData service data through the manifest without a named model, change tableBindingPath to: tableBindingPath="{/trainingPlan}"