技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
ui5-best-practices-mdc【数据与研究】UI5 MDC (Model-Driven Controls) best practices and authoritative development guidelines for OData V4 delegate-based controls. Use when the user asks to "create an MDC FilterBar", "implement MDC Chart", "add MDC Field", "use MDC FilterField", "implement ValueHelp", "add MDC Link", "MDC MultiValueField", "sap.ui.mdc", "delegate pattern", "fetchProperti…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: ui5-best-practices-mdc description: | UI5 MDC (Model-Driven Controls) best practices and authoritative development guidelines for OData V4 delegate-based controls. Use when the user asks to "create an MDC FilterBar", "implement MDC Chart", "add MDC Field", "use MDC FilterField", "implement ValueHelp", "add MDC Link", "MDC MultiValueField", "sap.ui.mdc", "delegate pattern", "fetchProperties", "OData V4 freestyle controls", "MDC personalization", "p13nMode", "PropertyInfo", "MDC delegate", "FilterBarDelegate", "ChartDelegate", "ValueHelpDelegate", "LinkDelegate", "MDC field not rendering", "MDC chart not binding", "MDC conditions", "Condition.createCondition", "MDC Table delegate", or is writing any UI5 freestyle application using OData V4 with model-driven controls from sap.ui.mdc. Covers: delegate pattern, PropertyInfo structure, mandatory rules, common error patterns, and per-control API reference for FilterBar, Chart, Field, FilterField, ValueHelp, Link, and MultiValueField.
Keywords: sap.ui.mdc, MDC, FilterBar, Chart, Field, FilterField, ValueHelp, Link, MultiValueField, delegate, fetchProperties, updateBindingInfo, PropertyInfo, OData V4, JSON model, JSONModel, custom delegate, TypeMap, DefaultTypeMap, base delegate, non-OData, addItem, getFilters, p13nMode, autoBindOnInit, conditions, TypeMap, FieldBase, FilterBarBase, ChartDelegate, ValueHelpDelegate, LinkDelegate, FilterBarDelegate, MultiValueFieldDelegate, Condition.createCondition
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 |
Working on or planning a sap.ui.mdc.Table | See ui5-best-practices-tables skill, references/mdc-table.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.