Skip to Content
0

Multi model bindings in sap.m Table

Mar 07 at 05:11 AM

53

avatar image
Former Member

HI All,

I am using a table control which is bound to one entityset model name: oDataSCME

As per new requirement I need to add a table column (Input) whose value will come from different service . ( it will be different entity set). Model name : NewModel

How can i achieve this?

One option is two merge two models "oDataSCME" and "NewModel" and create third model and bind dat model to Table.

But my concern is both this rest calls are asynchronous. And not sure at what time which service will get resolved first.

Is der any solution for it?

Any pointers highly appreciated

regards

Fehmina.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Mar 07 at 09:12 AM
0

thanks let me try it

Share
10 |10000 characters needed characters left characters exceeded
Nicholas Owen O’Malley Mar 07 at 06:46 AM
0

Not sure how to bind two models to one table, how ever, you can solve the async issue with a promise. Call one service, wait for it, then call the second one. Create a new model with the two results

Here is a smal example:

returnPromise: function(oModel){
return new Promise(function(resolve, reject) { oModel.read("/" , null, null, true, function(oData) { resolve(oData); }, function(oError) { reject(oError); }); }); },
calFunc: function(){ var this = that; var oModelFirst = new sap.ui.model.odata.ODataModel({serviceUrl: "url", json: true}); var oModelSecond = new sap.ui.model.odata.ODataModel({serviceUrl: "secondUrl", json: true}); this.returnPromise(oModelFirst).then(function(oData){ console.log(oData);
that.returnPromise(oModelSecond).then(function(secondOdata){ //Here you will have all the data console.log(secondOdata); }); }); }


Something like that. I have not tested this, only coded it in this editor, so some tweeks may be neede :)

Show 1 Share
10 |10000 characters needed characters left characters exceeded

PS:

This does not work with IE. IE will not get promise support when it its deprecated. You will need to use anything else.

Or you need a third party lib like http://bluebirdjs.com/docs/getting-started.html

0