使用公开的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"/>
但它不起作用。有什么建议吗?
答案 0 :(得分:2)
我已经向前迈了一步。我添加了以下代码:
onBeforeRebind: function(oEvent) { var mBindingParams = oEvent.getParameter("bindingParams"); mBindingParams.parameters["expand"] = "Supplier"; },
这就是如何在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>