Skip to Content

Multi model bindings in sap.m Table

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



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 07, 2018 at 09:12 AM

    thanks let me try it

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 07, 2018 at 06:46 AM

    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) {"/" , 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 :)

    Add comment
    10|10000 characters needed characters exceeded