harini88
harini88

Reputation: 151

SAPUI5 get oData model from table binding

I have binded a Table using oData like below.

<Table id="myTableID" 
            class="sapUiResponsiveMargin" 
            items="{Items}"
            noDataText="{i18n>NoDataText}" 
            updateFinished="onUpdateFinished"
            width="auto">

Now I need to retrieve this oData model from the view rather than calling the web service again.

I have tried the below,

var path = this.getView().getElementBinding().getPath();
var oModel = this.getView().getModel();

which returns the model from the parent view.

Is there a way to achieve this?

Upvotes: 3

Views: 11093

Answers (2)

Marc
Marc

Reputation: 6190

I assume that you want only the items that are bound to the table.

var sPath = oTable.getBindingPath("items");

This gives you the path that you have bound to the items aggregation.

var oModelObject = oTable.getModel().getProperty(sPath);

This fetches only the table bound objects from your model

Edit oTable is your table object. var oTable = this.getView().byId("myTableID");

Upvotes: 2

Qualiture
Qualiture

Reputation: 4920

Just use this.getView().byId("myTableID").getModel();

Upvotes: 2

Related Questions