UI5 MDC(SAP UIフレームワークのモデル駆動型コントロール)のOData V4との組み合わせにおけるベストプラクティスです。FilterBar、Chart、Field、FilterField、ValueHelp、Link、MultiValueField、Tableなどのコントロールを作成・トラブルシューティングする際に使用します。 デリゲートパターン(処理の委譲)、fetchProperties、PropertyInfo、p13nMode(個人用設定モード)、updateBindingInfo、Condition.createCondition、および一般的なエラー(デリゲートが読み込まれない、チャートにデータが表示されない、フィールドが表示されないなど)に対応しています。 JSONモデル(ODataではない通常のデータ形式)を使用するMDCの場合にも適用できます。 **対象となるユースケース:** - MDC、sap.ui.mdc、デリゲートパターンに関する質問 - fetchProperties、PropertyInfo、個人用設定モードの使用方法 - MDCフィールドが表示されない、チャートがデータにバインドされないなどの問題 - MDCの条件設定に関する事項 - OData V4を使用したモデル駆動型のUI開発 **対応キーワード:** sap.ui.mdc、FilterBar、Chart、Field、FilterField、ValueHelp、Link、MultiValueField、デリゲート、fetchProperties、updateBindingInfo、PropertyInfo、OData V4、JSONモデル、TypeMap、個人用設定モード、条件、FilterBarDelegate、ChartDelegate、ValueHelpDelegate、LinkDelegate、Condition.createCondition
UI5 MDC (sap.ui.mdc) best practices for OData V4 delegate-based controls. Use when creating/troubleshooting MDC FilterBar, Chart, Field, FilterField, ValueHelp, Link, MultiValueField, or Table. Covers delegate pattern, fetchProperties, PropertyInfo, p13nMode, updateBindingInfo, Condition.createCondition, and common errors (delegate not loaded, chart no data, fields not appearing). Also applies to JSON model (non-OData) MDC usage. Triggers: "MDC", "sap.ui.mdc", "delegate pattern", "fetchProperties", "PropertyInfo", "MDC personalization", "p13nMode", "MDC field not rendering", "MDC chart not binding", "MDC conditions", OData V4 freestyle with model-driven controls. Keywords: sap.ui.mdc, FilterBar, Chart, Field, FilterField, ValueHelp, Link, MultiValueField, delegate, fetchProperties, updateBindingInfo, PropertyInfo, OData V4, JSON model, TypeMap, p13nMode, conditions, FilterBarDelegate, ChartDelegate, ValueHelpDelegate, LinkDelegate, Condition.createCondition
OData V4サービスを使用するフリースタイルアプリケーションで、MDC(メタデータドリブン・コントロール)コントロールコードを生成・レビュー・トラブルシューティングする際には、以下のガイドラインを適用してください。
UI5バージョンの基準: SAPUI5 1.136+ LTS。特に記載がない限り、ここで紹介するすべての機能はこのバージョン以降で利用可能です。
| トリガー | 参照するドキュメント |
|---|---|
sap.ui.mdc.FilterBar を作成または計画する |
references/mdc-filter-bar.md |
sap.ui.mdc.Chart を作成または計画する |
references/mdc-chart.md |
sap.ui.mdc.Field を作成または計画する |
references/mdc-field.md |
sap.ui.mdc.FilterField を作成または計画する |
references/mdc-filter-field.md |
sap.ui.mdc.ValueHelp を作成または計画する |
references/mdc-value-help.md |
sap.ui.mdc.Link を作成または計画する |
references/mdc-link.md |
sap.ui.mdc.MultiValueField を作成または計画する |
references/mdc-multi-value-field.md |
| JSONモデルで MDCコントロールを使用する(OData以外) | references/mdc-json-delegates.md |
アウトプットを生成する前に必ずこれらを参照してください。記憶に頼らないでください。
すべての MDCコントロールは、デリゲート(処理の委譲元)を使用してコントロールをデータソース固有のロジックから切り離しています。アプリ開発者は次の手順が必要です:
delegate="{name: 'my/app/delegate/MyDelegate', payload: {entitySet: 'Products'}}"fetchProperties)をオーバーライドするOData V4用のベースデリゲート:
| コントロール | ベースデリゲート |
|---|---|
| Table(テーブル) | sap/ui/mdc/odata/v4/TableDelegate |
| FilterBar(フィルタバー) | sap/ui/mdc/odata/v4/FilterBarDelegate |
| Chart(グラフ) | sap/ui/mdc/odata/v4/vizChart/Delegate |
| ValueHelp(値の補助) | sap/ui/mdc/ValueHelpDelegate |
| Link(リンク) | sap/ui/mdc/LinkDelegate |
| MultiValueField(複数値フィールド) | sap/ui/mdc/field/MultiValueFieldDelegate |
JSONモデルの場合: MDCコントロールはJSONモデルでも動作します。OData V4バージョンではなく、ベースデリゲート(sap/ui/mdc/TableDelegate、sap/ui/mdc/FilterBarDelegate)を直接拡張してください。詳しくは references/mdc-json-delegates.md をご覧ください。
PropertyInfo — fetchProperties が返すコアメタデータ形式:
{
key: "propertyName", // 一意の識別子(必須)
label: "Display Label", // ユーザーに表示されるラベル(必須)
dataType: "sap.ui.model.odata.v4.type.String" // データ型(必須)
}
delegate プロパティが必要です。fetchProperties を実装し、最低限 key、label、dataType を含む PropertyInfo[] を返してください。p13nMode を使用してパーソナライゼーション(テーブルはColumn(列)、Sort(並べ替え)、Filter(フィルタ)、Group(グループ化);グラフはItem(項目)、Sort、Filter、Type(タイプ);フィルタバーはItem)を有効にしてください。sap.ui.mdc.condition.Condition.createCondition() を使用してください。dataType フィールドで OData V4モデルの場合は sap.ui.model.odata.v4.type.* タイプを、JSONモデルの場合は sap.ui.model.type.* を使用してください。TypeMapにタイプを登録してください。ariaLabelledBy を設定してください。get_api_reference MCPツール を使用してコントロール APIを確認してください。run_ui5_linter を使用してコードを検証してください。sap.ui.comp)を使用してください。MDCは OData V4と JSONモデルで動作します。sap.chart.Chart や sap.m.Table)に直接アクセスしないでください。デリゲートまたは MDCコントロールの公開 APIを使用してください。key を省略しないでください(以前の name は廃止されました)。Condition.createCondition(operator, values) を使用してください。sap.ui.mdc.FilterBar)を使用しないでください。sap.ui.define または ES6インポートを使用してください。| コントロール | 次のような場合に使用 | 次のような場合は使用しないでください |
|---|---|---|
MDC FilterBar |
OData V4または JSONモデル、デリゲート駆動フィルタUI、MDC Table/Chart | OData V2(SmartFilterBarを使用)、シンプルな検索バー |
MDC Chart |
OData V4、デリゲート駆動グラフ表示、ドリルダウン機能 | OData V2(SmartChartを使用)、シンプルな静的グラフ、分析データがない |
MDC Field |
OData V4または JSON、データ型に基づく自動レンダリング対応の単一フィールド | OData V2(SmartFieldを使用)、完全にカスタムなレンダリングが必要 |
MDC FilterField |
MDC FilterBar内の個別フィルタ条件用 | FilterBar外のスタンドアロンフィルタリング |
MDC ValueHelp |
OData V4または JSON、入力候補+ダイアログでの値選択 | OData V2(ValueHelpDialogを使用)、検索なしのシンプルドロップダウン |
MDC Link |
OData V4、セマンティックオブジェクトナビゲーション、デリゲート駆動リンク先 | OData V2(SmartLinkを使用)、シンプルな静的リンク |
MDC MultiValueField |
OData V4または JSON、items集約を通じた複数値トークン入力 | OData V2(SmartMultiInputを使用)、シンプルな単一値フィールド |
| 症状 | 原因 | 対処法 |
|---|---|---|
| 「Delegate module could not be loaded」(デリゲートモジュールが読み込めません) | delegate プロパティのパスが間違っている |
デリゲートプロパティのモジュールパスがプロジェクト内の実際のファイル位置と一致することを確認してください。 |
| グラフにデータが表示されない | fetchProperties が間違った PropertyInfoを返している(groupable/aggregatable がない) |
ディメンション(集計の軸)には groupable: true、メジャー(集計値)には aggregatable: true があることを確認してください。 |
| FilterBarのフィールドが表示されない | PropertyInfoが見当たらない、または hiddenFilter: true |
デリゲートの fetchProperties が正しい可視性を持つプロパティを返していることを確認してください。 |
| フィールドに予期しない内部コントロールが表示される | PropertyInfoの dataType が予期される形式と一致していない |
dataType が完全修飾型名(例:sap.ui.model.odata.v4.type.String)を使用していることを確認してください。 |
| パーソナライゼーションダイアログが空 | p13nMode が設定されていない、または PropertyInfoが不完全 |
p13nMode="Column,Sort,Filter" を追加し、PropertyInfoに sortable/filterable フラグがあることを確認してください。 |
| ValueHelpが開かない | ValueHelpが Field に接続されていない、またはコンテナが見当たらない | Field の valueHelp 関連付けを確認し、Popover/Dialogコンテナが定義されていることを確認してください。 |
| 条件がバインディングに適用されない | デリゲートに updateBindingInfo が実装されていない |
デリゲートに updateBindingInfo を実装して、フィルタ条件を ODataバインディングに適用してください。 |
| リンクが常にテキストとしてレンダリングされる | fetchLinkType が LinkType.Text を返すか失敗している |
Popup または DirectLink タイプを返すように fetchLinkType を実装してください。 |
fetchProperties から最小限のセットを返す)。updateBindingInfo を実装しない(条件がデータバインディングに適用されない)。p13nMode 設定をスキップする(パーソナライゼーション機能がデフォルトで無効化される)。ariaLabelledBy を設定し、表示されるタイトルを参照させてください。ariaLabelledBy を設定し、表示されるタイトルを参照させてください。label を通じて意味のあるラベルを持つことを確認してください。Apply these guidelines whenever generating, reviewing, or troubleshooting MDC control code in freestyle applications using OData V4 services.
UI5 version baseline: SAPUI5 1.136+ LTS. All features mentioned are available from this version unless noted.
| Trigger | Load |
|---|---|
Working on or planning a sap.ui.mdc.FilterBar |
references/mdc-filter-bar.md |
Working on or planning a sap.ui.mdc.Chart |
references/mdc-chart.md |
Working on or planning a sap.ui.mdc.Field |
references/mdc-field.md |
Working on or planning a sap.ui.mdc.FilterField |
references/mdc-filter-field.md |
Working on or planning a sap.ui.mdc.ValueHelp |
references/mdc-value-help.md |
Working on or planning a sap.ui.mdc.Link |
references/mdc-link.md |
Working on or planning a sap.ui.mdc.MultiValueField |
references/mdc-multi-value-field.md |
| Using MDC controls with JSON model (non-OData) | references/mdc-json-delegates.md |
Load before producing any output. Do not work from memory.
All MDC controls use a delegate to decouple the control from data-source-specific logic. App developers must:
delegate="{name: 'my/app/delegate/MyDelegate', payload: {entitySet: 'Products'}}"fetchProperties)Base delegates for OData V4:
| Control | Base Delegate |
|---|---|
| Table | sap/ui/mdc/odata/v4/TableDelegate |
| FilterBar | sap/ui/mdc/odata/v4/FilterBarDelegate |
| Chart | sap/ui/mdc/odata/v4/vizChart/Delegate |
| ValueHelp | sap/ui/mdc/ValueHelpDelegate |
| Link | sap/ui/mdc/LinkDelegate |
| MultiValueField | sap/ui/mdc/field/MultiValueFieldDelegate |
JSON model usage: MDC controls also work with JSON models. Extend the base delegates directly (sap/ui/mdc/TableDelegate, sap/ui/mdc/FilterBarDelegate) — not the OData V4 variants. See references/mdc-json-delegates.md for details.
PropertyInfo — the core metadata format returned by fetchProperties:
{
key: "propertyName", // Unique identifier (required)
label: "Display Label", // User-visible label (required)
dataType: "sap.ui.model.odata.v4.type.String" // Data type (required)
}
delegate property pointing to a valid module path.fetchProperties in the delegate returning PropertyInfo[] with at minimum: key, label, dataType.p13nMode to enable personalization (Column, Sort, Filter, Group for Table; Item, Sort, Filter, Type for Chart; Item for FilterBar).sap.ui.mdc.condition.Condition.createCondition() to construct conditions programmatically.sap.ui.model.odata.v4.type.* types in PropertyInfo dataType field for OData V4 models. Use sap.ui.model.type.* with JSON models. Register types in the TypeMap.ariaLabelledBy on FilterBar and Chart for accessibility.get_api_reference MCP tool to verify control APIs. Use run_ui5_linter to validate code.sap.ui.comp) instead. MDC works with OData V4 and JSON models.sap.chart.Chart or sap.m.Table). Use the delegate or MDC control's public API.key from PropertyInfo objects (formerly name, now deprecated).Condition.createCondition(operator, values).sap.ui.mdc.FilterBar). Use sap.ui.define or ES6 imports.| Control | Use when | Do not use when |
|---|---|---|
MDC FilterBar |
OData V4 or JSON model, delegate-driven filter UI, MDC Table/Chart | OData V2 (use SmartFilterBar), simple search bar |
MDC Chart |
OData V4, delegate-driven chart visualization, drill-down | OData V2 (use SmartChart), simple static charts, no analytical data |
MDC Field |
OData V4 or JSON, single field with auto-rendering by data type | OData V2 (use SmartField), purely custom rendering needed |
MDC FilterField |
Inside MDC FilterBar for individual filter conditions | Standalone filtering outside FilterBar context |
MDC ValueHelp |
OData V4 or JSON, type-ahead + dialog value selection | OData V2 (use ValueHelpDialog), simple dropdowns without search |
MDC Link |
OData V4, semantic object navigation, delegate-driven link targets | OData V2 (use SmartLink), simple static links |
MDC MultiValueField |
OData V4 or JSON, multi-value token entry via items aggregation | OData V2 (use SmartMultiInput), simple single-value fields |
| Symptom | Cause | Fix |
|---|---|---|
| "Delegate module could not be loaded" | Wrong path in delegate property |
Verify module path matches actual file location in project. |
| Chart shows no data | fetchProperties returns wrong PropertyInfo (missing groupable/aggregatable) |
Ensure dimensions have groupable: true, measures have aggregatable: true. |
| FilterBar fields not appearing | PropertyInfo missing or hiddenFilter: true |
Check delegate fetchProperties returns properties with correct visibility. |
| Field shows wrong inner control | dataType in PropertyInfo doesn't match expected format |
Verify dataType uses full qualified type name (e.g., sap.ui.model.odata.v4.type.String). |
| Personalization dialog empty | p13nMode not set or PropertyInfo incomplete |
Add p13nMode="Column,Sort,Filter" and ensure PropertyInfo has sortable/filterable flags. |
| ValueHelp not opening | ValueHelp not connected to Field or containers missing | Verify valueHelp association on Field and that Popover/Dialog containers are defined. |
| Conditions not applied to binding | updateBindingInfo not implemented in delegate |
Implement updateBindingInfo to apply filter conditions to the OData binding. |
| Link always rendered as text | fetchLinkType returns LinkType.Text or fails |
Implement fetchLinkType returning Popup or DirectLink type. |
fetchProperties).updateBindingInfo (conditions are never applied to the data binding).p13nMode configuration (personalization features are disabled by default).ariaLabelledBy on FilterBar referencing a visible title.ariaLabelledBy on Chart referencing a visible title.label.原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。