【问题标题】:No Data coming in SmartTableSmartTable 中没有数据
【发布时间】:2016-12-14 14:49:29
【问题描述】:

我正在尝试使用 Smart Table 调用 OData 服务。首先,我创建了一个简单的表格,通过它我可以看到表格中的数据。然后我在同一页面上添加了 SmartTable,但它没有显示任何数据。甚至没有创建列。可能是什么原因?

<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>

我在 neo-app.json 文件中创建了目的地,并在 Manifest.json 文件中创建了模型。

问候, 马扬克

【问题讨论】:

    标签: sapui5


    【解决方案1】:

    我必须在 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>
    

    【讨论】:

      【解决方案2】:

      您有一个名为“发票”的模型。根据documentation 命名的模型不支持智能控件。

      【讨论】:

      • 嗨,Matbtt,是的,我已经删除了它。发帖后我看到了。但它仍然无法正常工作。
      • @Mayank:日志中有错误吗?在发现命名模型不起作用后更新问题会很有用。
      • 嗨垫,谢谢你的回复。日志中没有错误。当我检查 lineItem 是否存在注释标签时,我想在我的 Odata 服务中再添加一件事。你认为这是强制性的吗?
      • 您是否为智能表提供必要的元数据?智能表需要 LineItem 元数据。
      • 您好 Schmitt,不,我们没有为 Odata 定义 LineItem 元数据。所以我不得不手动创建默认列并且它起作用了。
      【解决方案3】:

      如果您的 oData 服务支持注释,您也可以使用注释文件。新建注解文件,注解实体集,添加LineItem/DataField注解。这应该会显示您选择的字段。

                  <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>
      

      如果您喜欢 oData 字段名称,则可以省略“标签”属性。

      【讨论】:

        【解决方案4】:

        我刚遇到这个错误。

        这可以通过添加来解决

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

        在视图的顶部。虽然我找不到添加这个的任何原因/解释,但我相信这与 FlexItemData 有关。

        【讨论】:

          猜你喜欢
          • 2020-10-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-05-01
          • 1970-01-01
          相关资源
          最近更新 更多