我有一个odata服务,该服务提供了一组对象(即列标题)。如何将这些数据绑定到我的表列上。
我需要动态获取Columns的所有数据,并使用它来设置sap m表的列,并使用'Fieldname'属性设置列描述。
试图将我的视图数据(列)绑定到该列,但是这并不像将其应用于Table组件时那样。
<columns items="{view>/Columns}">
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{view>Fieldname}"/>
</Column>
</columns>
这可以通过视图动态完成吗?
下面是我当前使用静态列解决方案的设置。
<!-- Production Plan Table -->
<Table id="ProdPlanTable" items="{view>/MatchingOrders}" class="table">
<!--Table Header Toolbar-->
<headerToolbar>
<Toolbar class="toolbarHeader sapUiMediumMarginTop">
<content>
<!-- Planner Group filter -->
<VBox>
<Label text="{i18n>PlannerGroupHdr}"/>
<Select id="selectPG" items="{path: 'view>/FilterPlannerGroup', sorter: {path: 'Id'}}" change="onFilterSelect" selectedKey="{view>/FilterPlannerGroup/PlannerGroup}" width="200px">
<items>
<core:ListItem text="{view>PlannerGroup}" key="{view>PlannerGroup}"/>
</items>
</Select>
</VBox>
<!-- Status filter -->
<VBox>
<Label text="{i18n>StatusHdr}"/>
<Select id="selectSTA" items="{path: 'view>/FilterStatus', sorter: {path: 'Id'}}" change="onFilterSelect" selectedKey="{view>/FilterStatus/Status}" width="200px">
<items>
<core:ListItem key="{view>Status}" text="{view>Status}"/>
</items>
</Select>
</VBox>
<!-- Required / Delivered UoM -->
<VBox>
<Label text="{i18n>UoMHdr}"/>
<Select items="{view>/FilterUoM}" change="onUoMSelect" selectedKey="{view>/SelectedUoMId}" width="200px">
<items>
<core:ListItem key="{view>UoMText}" text="{view>UoMText}"/>
</items>
</Select>
</VBox>
<!-- Toolbar Spacer -->
<ToolbarSpacer/>
<!-- Refresh button -->
<VBox>
<Label text=""/>
<Button text="{view>/LastRefreshTimeFormatted}" icon="sap-icon://refresh" type="Accept" press="refreshWithoutFilters"/>
</VBox>
</content>
</Toolbar>
</headerToolbar>
<!-- Headers -->
<!--<columns items="{view>/Columns}">-->
<!-- <Column minScreenWidth="Tablet" demandPopin="true">-->
<!-- <Text text="{view>/Columns/Fieldname}"/>-->
<!-- </Column>-->
<columns>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>PlannerGroup}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>ProcessOrder}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Info}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Article}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="End">
<Text text="{i18n>OrderQty}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="End">
<Text text="{i18n>RequiredQty}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="End">
<Text text="{i18n>DeliveredQty}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>Status}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>StartDateTime}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>EndDateTime}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>LongText}"/>
</Column>
</columns>
<!-- Items -->
<items>
<ColumnListItem type="Inactive">
<Text text="{view>PlannerGroup}"/>
<Text text="{view>ProcessOrder}"/>
<Text text="{view>GoodsRecipient}"/>
<ObjectIdentifier title="{view>Article}" text="{view>ArticleDescription}"/>
<ObjectNumber number="{path: 'view>RequiredQty', formatter: '.formatter.numberThousands'}" unit="{view>OrderUOM}"/>
<Text text="{path: 'view>SelectedUoMQty/RequiredQty', formatter: '.formatter.numberThousands'}"/>
<Text text="{path: 'view>SelectedUoMQty/DeliveredQty', formatter: '.formatter.numberThousands'}"/>
<Text text="{view>Status}"/>
<Text text="{path: 'view>StartDay', formatter: '.formatter.date'}, {path: 'view>StartTime', formatter: '.formatter.time'}"/>
<Text text="{path: 'view>EndDay', formatter: '.formatter.date'}, {path: 'view>EndTime', formatter: '.formatter.time'}"/>
<Button icon="{= ${view>LongTextExists} ? 'sap-icon://attachment-text-file' : 'sap-icon://add-document'}" type="{= ${view>LongTextExists} ? 'Emphasized' : 'Default'}" press="onOpenProductionNote"/>
</ColumnListItem>
</items>
</Table>