私はSAPUI5アプリケーションで作業しており、sap.ui.comp.smarttable.SmartTableを使用してデータレコードのリストを表示したいとします。sap.ui.comp.smarttable.SmartTableで複雑なODataプロパティタイプを表示するには?
Smart Table samples from the SAPUI5 Explored Appで悩んでいます。モックサーバーが提供するODataサービスに対してスマートテーブルを実行することができました。あなたはデータレコードがタイプmy.namespace.ShortReference
の複雑な性質を持って見ることができるようにmetadata.xml
<Schema Namespace="my.namespace" sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<ComplexType Name="ShortReference">
<Property Name="Type" Type="Edm.String" Nullable="false" sap:label="Reference type" />
<Property Name="Key" Type="Edm.String" Nullable="false" sap:label="Reference key" />
</ComplexType>
<EntityType Name="Record" sap:label="Record" sap:content-version="1">
<Key>
<PropertyRef Name="RecordID" />
</Key>
<Property Name="RecordID" Type="Edm.String" Nullable="false" sap:label="Record ID" sap:creatable="false" sap:updatable="false" />
<Property Name="ShortReference" Type="my.namespace.ShortReference" />
</EntityType>
<EntityContainer Name="my.namespace.Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
<EntitySet Name="RecordSet" EntityType="my.namespace.Record" />
</EntityContainer>
<!-- Default columns shown by Smart Table -->
<Annotations Target="my.namespace.Record" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="com.sap.vocabularies.UI.v1.LineItem">
<Collection>
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="RecordID" />
</Record>
<!-- The following doesn't work - it won't be shown in a Smart Table column -->
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="ShortReference/Key" />
</Record>
<Record Type="com.sap.vocabularies.UI.v1.DataField">
<PropertyValue Property="Value" Path="ShortReference/Type" />
</Record>
</Collection>
</Annotation>
</Annotations>
</Schema>
のラインを対応
XMLビューでスマート表
<smartTable:SmartTable tableType="ResponsiveTable"
entitySet="RecordSet" enableAutoBinding="true" />
。私は2つのプロパティを別々の列としてスマートテーブルに表示してそれらをフィルタリングできるようにします。
は私が 、次のように<customData>
集約を使用してほとんど成功を持っていたが、私は(別の複雑な実体を持つ複雑なエンティティを含む)は、この単一の複雑な実体以上を抱えているように私は、よりシンプルで堅牢を探していますその目標を達成する方法。さらに、<customData>
では、p13nダイアログのフィルター機能が制限されています(contains
、starts with
などのフィルターを使用する可能性はありません)。
だから、カスタムデータ
<smartTable:SmartTable tableType="ResponsiveTable"
entitySet="RecordSet" enableAutoBinding="true" >
<Table>
<!-- http://stackoverflow.com/questions/32114675/sapui5-smart-table-how-to-inject-my-own-column-into-smart-table-default-colum -->
<!-- Smart Table Developer Guide: https://sapui5.hana.ondemand.com/#docs/guide/bed8274140d04fc0b9bcb2db42d8bac2.html -->
<columns>
<!-- Reference -->
<Column>
<customData>
<core:CustomData
key="p13nData"
value='\{
"columnKey": "ReferenceType",
"leadingProperty": "ShortReference/Type",
"sortProperty": "ShortReference/Type",
"filterProperty": "ShortReference/Type",
"columnIndex": "9"
}' />
</customData>
<Label text="Reference type"/>
</Column>
<Column>
<customData>
<core:CustomData
key="p13nData"
value='\{
"columnKey": "ReferenceKey",
"leadingProperty": "ShortReference/Key",
"sortProperty": "ShortReference/Key",
"filterProperty": "ShortReference/Key",
"columnIndex": "10"
}' />
</customData>
<Label text="Reference key"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{ShortReference/Type}" />
<Text text="{ShortReference/Key}" />
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
スマート表、これは達成することも可能でしょうか?または、ODataエンティティを平坦化する必要がありますか?
さらに簡単なら通常のsap.m.Table
に変更します。私はそれがソート、フィルタリング、グループ化能力とバリアント管理(私はそれらのすべてが必要です)のためにスマートテーブルを選択しました。