2017-01-04 26 views
1

私は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ダイアログのフィルター機能が制限されています(containsstarts 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に変更します。私はそれがソート、フィルタリング、グループ化能力とバリアント管理(私はそれらのすべてが必要です)のためにスマートテーブルを選択しました。

答えて

0

私はしばらくの間、解決策を探しましたが、上記のエンティティ構造に一致する満足のいく解決策は見つかりませんでした。

そこで私は、これが実現することも可能ですので、

  • を次のように私の質問に答える必要がありますか? No.
  • ODataエンティティをフラット化する必要がありますか?はい。

マイリストは、特定のレコードセットの概要を示し、詳細ページに移動します。概要リストではすべてのプロパティが必要なわけではないので、スマートテーブルを実行するために新しいエンティティRecordOverviewを作成しました。 (追加や変更のみを示す)

のmetadata.xml

<Schema Namespace="my.namespace" sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"> 

    ... 

    <EntityType Name="RecordOverview" 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="ReferenceKey" Type="Edm.String" Nullable="false" sap:label="Reference key" /> 
    </EntityType> 

    <EntityContainer Name="my.namespace.Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx"> 
     <EntitySet Name="RecordSet" EntityType="my.namespace.Record" /> 
     <EntitySet Name="RecordOverviewSet" EntityType="my.namespace.RecordOverview" /> 
    </EntityContainer> 

    <!-- Default columns shown by Smart Table --> 
    <Annotations Target="my.namespace.RecordOverview" 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> 
       <Record Type="com.sap.vocabularies.UI.v1.DataField"> 
        <PropertyValue Property="Value" Path="ReferenceKey" /> 
       </Record> 
       ... 
      </Collection> 
     </Annotation> 
    </Annotations> 
</Schema> 

はしかし、素敵な(側)の効果は、私はもう私のXMLビューの列を指定する必要はありませんです。

XMLビュー

<smartTable:SmartTable entitySet="RecordOverviewSet" enableAutoBinding="true"> 
    <Table> 
     <items> 
      <ColumnListItem vAlign="Middle" type="Navigation" press="onListItemPressed" /> 
     </items> 
    </Table> 
</smartTable:SmartTable> 
関連する問題