如何在SAPUI5中使用oData v4创建sap.ui.mdc.table.TreeTable

问题描述 投票:0回答:1

我们需要创建一个智能树表,但由于数据源是OData v4,所以我们需要使用SAP.UI.MDC库。

在 SAP 提供的现有示例中,它使用 JSONPropertyInfo 作为元数据,但在这种情况下,元数据将来自 OData v4。所以不确定如何在委托文件中使用它。

如果有人实现了此类要求,期待社区的帮助。

下面是SAP提供的从JSONPropertyinfo.js文件中提取元数据注释的参考方法。 我们想直接使用 OData v4 元数据

const _createColumn = (sId, oPropertyInfo) => {
    const sPropertyName = oPropertyInfo.name;
    return new Column(sId, {
        propertyKey: sPropertyName,
        header: oPropertyInfo.label,
        template: new Text({
            text: {
                path: "mountains>" + sPropertyName,
                type: oPropertyInfo.dataType
            }
        })
    });
};
odata sapui5 metadata sap-fiori
1个回答
0
投票

我相信ODataV4和TreeTable的用例可以在https://sapui5.hana.ondemand.com/#/api/sap.ui.table.TreeTable%23overview的帮助下实现。尝试通过行将其绑定到所需的实体https://sapui5.hana.ondemand.com/#/api/sap.ui.table.TreeTable%23aggregations。此外,您将需要解析实体的注释,以便显示正确的标签、列等。

另请参阅https://sapui5.hana.ondemand.com/#/api/sap.ui.base.ManagedObject.AggregationBindingInfo.

示例:

XML 片段

<table:TreeTable id="yourTable">
</table:TreeTable>

控制器代码

const table = <get your table>;
table.bindRows(<AggregationBindingInfo for your table>);
await fetchAnnotations4Table();
parseAnnotations2BuildColumns&More();
© www.soinside.com 2019 - 2024. All rights reserved.