-4

I'm just starting with SAP FIORI app developing.

I created simple oData model for SAP user details, I implemented two methods:

  • get_entityset - receives list of users with personal number and full name
  • get_entity - receives more details of single user (by username).

When I call the service from browser all works fine. How do I call my get_entity method when loading detail page of Master-Detail FIORI app. I used Master-Detail template from WebIDE, but only get_entitset is called and detail screen uses only set data.

How should I define the data binding (in Detail controller I guess)?

4

1 回答 1

2

假设您的实体称为用户,您的实体集称为用户。我们还假设您的实体有一个名为 UserId 的 Edm.String 类型的关键字段和另一个名为 FullName 的 Edm.String 类型的字段。

var sPath = "/the/path/to/my/service";
var oModel = new sap.ui.model.odata.ODataModel(sPath);
sap.ui.getCore().setModel(oModel);
var oText = new sap.ui.commons.TextView({
    text: "{FullName}"
});   
oText.bindElement("/Users('MyUserId')");  
oText.placeAt("content");

由于您绑定到“/Products('MyProductId')”,因此调用了“get_entity”。绑定到“/Products”将调用“get_entityset”。但是,对“/Products”的绑定用于表或列表,通常不用于简单的 TextView(如上面的示例)。网上有很多教程,你会发现这并不像你想象的那么复杂。

于 2015-08-24T09:51:52.040 回答