How to bind an entity object on a Detail page

后端 未结 1 1725
终归单人心
终归单人心 2021-01-22 01:15

I am developing a master detail Fiori app using SAP UI5. As the details contains more than 40 columns, I made separate OData services for master & detail.

In Master p

相关标签:
1条回答
  • 2021-01-22 01:45

    The purpose of the sap.ui.model.Filter class is usually to apply filters to lists on the UI. For example, if you have a list of items and you want to limit that list to a subset of items which fulfills certain criteria.

    But what you have here appears to be a classic master-detail scenario where you have a list of items and then when the user selects one show more information about that one item.

    The usual solution for such a scenario is to assign the full model to the detail-view and then use an element binding (also known as "context binding") on the view to tell it which item to display.

    When the source of the item is a click on an element which already had an element binding, then you can actually retrieve the correct binding path from the click event and just apply it to your detail-view.

    From one of the official demos:

    onItemSelected: function(oEvent) {
        var oSelectedItem = oEvent.getSource();
        var oContext = oSelectedItem.getBindingContext("products");
        var sPath = oContext.getPath();
        var oProductDetailPanel = this.byId("productDetailsPanel");
        oProductDetailPanel.bindElement({ path: sPath, model: "products" });
    }
    

    When you don't have any convenient way to get an element path from, then you have to construct one yourself:

    var detailPanel = this.getView().byId("idOfDetailPanel");
    detailPanel.bindElement("PdetailSet(Laufi = " + spayid +", Laufd = " + spaydt + ")");
    

    The latter code snippet does of course assume that the oData-service actually supports access with a key consisting of laufi and laufd. This is decided by:

    • The definition of the key fields of the entity type in the SAP Gateway Service Builder (transaction SEGW)
    • The ABAP implementation of the method get_entity of the data provider class of that oData-service.
    0 讨论(0)
提交回复
热议问题