简体   繁体   中英

How to convert OData model to entityset in sap ui5

I want to use smart Table like in this sapui5 explored sample but the problem is I have a OData model and the example shows only how we can handle the binding with mock data and also I didn't understand the metadata.xml file. I guess oData model has also its own metadata document. Here my codes in controller :

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);

but it doesn't work. I got this error :

Component-changes.json could not be loaded from ./Component-changes.json. Check for 'file not found' or parse errors. Reason: Not Found -

getChanges' failed: -

Simply how can I set entitySet using my odata model?

my view:

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

Thank you in advance if someone can help.

UPDATE 2 : I rebind table according to this discussion

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();

sad to say but still I got same error.

You need to pass the name of entity set, not the model instance. If you have for example an entity set Customers defined you just do:

oSmartTable.setEntitySet("Customers");

or add the attribute entitySet to your table declaration.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM