SAPUI5 智能 table 展开
SAPUI5 Smart table expand
使用公开可用的 Nortwhind oData v2 服务,我可以使用以下代码在正常 sap.m.Table 中扩展产品和供应商实体:
<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>
现在如何使用智能 table 实现相同的输出?基于此 我尝试了以下操作:
<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"/>
但它不起作用。有什么建议吗?
我更进了一步。我添加了以下代码:
onBeforeRebind: function(oEvent) {
var mBindingParams = oEvent.getParameter("bindingParams");
mBindingParams.parameters["expand"] = "Supplier";
},
启动 beforeRebindTable 事件。它触发在后端获取展开的实体集。问题是我仍然只能看到第一个实体的列,因为它是在 entitySet 参数中指定的。有没有办法显示其他实体的列?
I have moved a step further. I have added the following code:
onBeforeRebind: function(oEvent) { var mBindingParams = oEvent.getParameter("bindingParams");
mBindingParams.parameters["expand"] = "Supplier"; },
这就是如何在 Smarttables 上使用 $expand
Is there any way to display columns from the other entity?
仅通过 NavigationProperty。您需要像下面提到的那样扩展您的智能表列:
<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>
使用公开可用的 Nortwhind oData v2 服务,我可以使用以下代码在正常 sap.m.Table 中扩展产品和供应商实体:
<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>
现在如何使用智能 table 实现相同的输出?基于此
<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"/>
但它不起作用。有什么建议吗?
我更进了一步。我添加了以下代码:
onBeforeRebind: function(oEvent) {
var mBindingParams = oEvent.getParameter("bindingParams");
mBindingParams.parameters["expand"] = "Supplier";
},
启动 beforeRebindTable 事件。它触发在后端获取展开的实体集。问题是我仍然只能看到第一个实体的列,因为它是在 entitySet 参数中指定的。有没有办法显示其他实体的列?
I have moved a step further. I have added the following code:
onBeforeRebind: function(oEvent) { var mBindingParams = oEvent.getParameter("bindingParams"); mBindingParams.parameters["expand"] = "Supplier"; },
这就是如何在 Smarttables 上使用 $expand
Is there any way to display columns from the other entity?
仅通过 NavigationProperty。您需要像下面提到的那样扩展您的智能表列:
<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>