首页 文章

SAPUI5智能表扩展

提问于
浏览
0

使用公开的Nortwhind oData v2服务,我可以使用以下代码在正常的sap.m.Table中扩展Product and Supplier实体:

<Table 
    id="table" 
    width="auto" 
    class="sapUiResponsiveMargin" 
    items="{ 
        path: '/Products', 
        parameters : { expand: 'Supplier' } 
    }">
    <columns>
        <Column id="nameColumn">
            <Text 
                text="{i18n>tableNameColumnTitle}" 
                id="nameColumnTitle" />
        </Column>
        <Column hAlign="End">
            <Text text="test" />
        </Column>
    </columns>
    <items>
        <ColumnListItem 
            type="Navigation" 
            press="onPress">
            <cells>
                <ObjectIdentifier title="{ProductName}"/>
                <Text text="{Supplier/CompanyName}"/>
            </cells>
        </ColumnListItem>
    </items>
</Table>

现在如何使用智能表实现相同的输出?基于此post我尝试了以下内容:

<sap.ui.comp.smarttable:SmartTable 
    xmlns:sap.ui.comp.smarttable="sap.ui.comp.smarttable" 
    tableType="ResponsiveTable" 
    header="Smart Table"
    enableAutoBinding="true" 
    entitySet="Products" 
    initiallyVisibleFields="ProductName" 
    tableBindingPath="Supplier"/>

但它没有用 . 有什么建议?

2 回答

  • 0

    我已经迈出了一步 . 我添加了以下代码:onBeforeRebind:function(oEvent){var mBindingParams = oEvent.getParameter(“bindingParams”);
    mBindingParams.parameters [“expand”] =“供应商”; },

    那就是如何在Smarttables上使用$ expand

    有没有办法显示其他实体的列?

    仅通过NavigationProperty . 你需要像下面提到的那样扩展你的smarttable列:

    <smartTable:SmartTable 
            entitySet="Products"
            tableType="ResponsiveTable"
            header="Products" showRowCount="true"
            enableAutoBinding="true"
            class="sapUiResponsiveContentPadding">
            <Table>
                <columns>
                    <Column width="100px" hAlign="Left">
                        <customData>
                            <core:CustomData key="p13nData"
                                value='\{"columnKey": "p13nDataKey",  "columnIndex":"4", "leadingProperty": "Supplier"}' />
                        </customData>
                        <Text text="{/#Supplier/Name/@sap:label}" />
                    </Column>
                </columns>
                <items>
                    <ColumnListItem>
                        <cells>
                            <Text
                                text="{Supplier/Name}" />
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>
        </smartTable:SmartTable>
    
  • 2

    我更进了一步 . 我添加了以下代码:

    onBeforeRebind: function(oEvent) {
    var mBindingParams = oEvent.getParameter("bindingParams");
        mBindingParams.parameters["expand"] = "Supplier";
    },
    

    在beforeRebindTable事件中启动 . 它触发后端中的get扩展实体集 . 问题是我仍然只能看到第一个实体中的列,因为它在entitySet参数中指定 . 有没有办法显示其他实体的列?

相关问题