如何在 sap ui5 中将 OData 模型转换为实体集

How to convert OData model to entityset in sap ui5

我想像在这个 sapui5 explored sample 中那样使用智能 Table 但问题是我有一个 OData 模型,该示例仅显示了我们如何处理与模拟数据的绑定,而且我也没有' 了解 metadata.xml 文件。我想 oData 模型也有自己的元数据文档。这是我在控制器中的代码:

this.DataPath = "QuarterPerformanceSet";
var oModel = new sap.ui.model.odata.ODataModel(model.Config.getServiceUrl(), true, model.user, password); 
oModel.setCountSupported(false);
oSmartTable.setModel(oModel);
oSmartTable.setEntitySet(this.DataPath);

但它不起作用。我收到此错误:

无法从 ./Component-changes.json 加载组件-changes.json。检查 'file not found' 或解析错误。原因:未找到 -

getChanges' 失败:-

如何使用我的 odata 模型设置 entitySet?

我的看法:

<smartTable:SmartTable id="idSmartTable" tableType="Table" 
useExportToExcel="true" useVariantManagement="false" 
useTablePersonalisation="true" header="Line Items" showRowCount="true"
persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true"/>

如果有人能提供帮助,在此先感谢您。

更新 2:我根据这个 discussion

重新绑定 table
this.DataPath = "QuarterPerformanceSet";
var oModel = new sap.ui.model.odata.ODataModel(model.Config.getServiceUrl(), true, model.user, password); 
oModel.setCountSupported(false);
var oSmartTable = this.getView().byId("idSmartTable");
oSmartTable.setModel(oModel);
oSmartTable.setEntitySet(this.DataPath);
oSmartTable.rebindTable();

很遗憾,但我仍然遇到同样的错误。

您需要传递实体集的名称,而不是模型实例。例如,如果您有一个客户定义的实体集,您只需执行以下操作:

oSmartTable.setEntitySet("Customers");

或将属性 entitySet 添加到您的 table 声明中。

<smartTable:SmartTable id="idSmartTable" entitySet="ENTITY_SET" .../>