0
votes

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.

1

1 Answers

1
votes

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" .../>