1
votes

I am trying to call the OData service with Smart Table. First I created a simple table and with that I am can see the data in table. Then I added SmartTable on the same page but It is showing no data. Even no columns are being created. What could be the reason ?

<mvc:View controllerName="com.siemens.hc.controller.View1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
    xmlns="sap.m" xmlns:smartField="sap.ui.comp.smartfield" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
    xmlns:smartTable="sap.ui.comp.smarttable">
    <App>
        <pages>
            <Page title="{i18n>title}">
                <content>                   
                        <Table id="idProductsTable" inset="false" items="{/SafetyUpdateSet}">
                            <headerToolbar>
                                <Toolbar>
                                    <Title text="Product" level="H2"/>
                                </Toolbar>
                            </headerToolbar>
                            <columns>
                                <Column width="12em">
                                    <Text text="Product"/>
                                </Column>
                            </columns>
                            <items>
                                <ColumnListItem>
                                    <cells>
                                        <ObjectIdentifier title="{Notification}"/>
                                    </cells>
                                </ColumnListItem>
                            </items>
                        </Table>

                    <smartTable:SmartTable id="smartTable_ResponsiveTable" tableType="ResponsiveTable" editable="false" entitySet="SafetyUpdateSet"
                        useVariantManagement="false" useTablePersonalisation="false" header="Notification" showRowCount="true" useExportToExcel="false"
                        enableAutoBinding="true">                           
                    </smartTable:SmartTable>
                </content>
            </Page>
        </pages>
    </App>
</mvc:View>

I have created the destination in neo-app.json file and created the model in Manifest.json file.

Regards, Mayank

4

4 Answers

1
votes

I had to defined the columns Manually in my SmartTable.

<smartTable:SmartTable id="smartTable_ResponsiveTable" tableType="ResponsiveTable" editable="false" entitySet="EntitySet"
                    useVariantManagement="false" useTablePersonalisation="false" header="Notification" showRowCount="true" useExportToExcel="false"
                    enableAutoBinding="true" initiallyVisibleFields="Col1,Col2,Col3,Col4,Col5"></smartTable:SmartTable>
0
votes

You have a model named "invoice". According to the documentation named models are not supported by smart controls.

0
votes

You can also use an annotation file, provided your oData service supports annotations. Create a new annotation file, annotate the entity set, and add LineItem/DataField annotations. That should display the fields you selected.

            <Annotations Target="<oData.Service>">
            <Annotation Term="UI.LineItem">
                <Collection>
                    <Record Type="UI.DataField">
                        <PropertyValue Property="Value" Path="Field1"/>
                        <PropertyValue Property="Label" String="{i18n>Field1Label}"/>
                    </Record>
                    <Record Type="UI.DataField">
                        <PropertyValue Property="Value" Path="Field2"/>
                        <PropertyValue Property="Label" String="{i18n>Field2Label}"/>
                    </Record>
                    <Record Type="UI.DataField">
                        <PropertyValue Property="Value" Path="Field3"/>
                        <PropertyValue Property="Label" String="{i18n>Field3Label}"/>
                    </Record>
                </Collection>
            </Annotation>
        </Annotations>

You can leave out the 'label' properties if you oData field names are to your liking.

0
votes

I just faced this error.

This may be resolved by adding

xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"

at the top of view. Although I could not find any reason/explanation of adding this, but I believe this is related to FlexItemData.