RaulCB
RaulCB

Reputation: 79

OData error when bind to an element in a Master-Detail app

I have developed a Master-Detail app. In the Detail view, I am using a DynamicPage where within content, I am using an IconTabBar Element with 3 items. Each item is a different Fragment with a Smartform.

Master view is loading the data from an EntitySet (MasterEntity)

Detail view with a is using some fields from the Entity MasterEntity

Fragment 1: is using DetailEntitySet

Fragment 2: is using DetailEntitySet

Fragment 3: is using DetailEntitySet

Basically, when Detail View Controller is detecting the RouteMatch, I am receiving the selected line on Master View and I bind it to the View Detail. Once it is done, I am checking if the view was generated and then, calling a method to bind the Expanded entity to the iconTabBar Element which contains the 3 Fragments. The code is as follows:

function _onRoutePatternMatched(event) {
    if (event.getParameter("name") === "detail") {
        var path = event.getParameter("arguments").contextPath;
        if (path !== " ") {
            var path2 = "/" + path;
            view.bindElement(path2);
            if (view) {
                this._setBindingToIconTab("Master2Detail");
            }
        } else {
            view.unbindElement();
        }
    }
}

The _setBindingToIconTab function is as follows:

_setBindingToIconTab: function (sAssociation) {
    view.byId("iconTabBar").bindElement(sAssociation);
}

iconTabBar is the ID I have assigned within the Detail view to the IconTabBar Element.

The problem is, when I execute it and it loads the first Fragment, all is ok. With the 2nd and 3rd, I got errors (but the values are displayed...). I am loading the Fragments when they are picked on the screen. If they were not generated, I instantiate and store them in an array. The errors I got are:

Assertion failed: The EDM property "DateFrom" was not found in the "ZZODATA_TEST_SRV.Master" entity type. - sap.ui.comp.smartfield.ODataControlFactory

It is complaining about Fields from DetailEntitySet are not in MasterEntitySet.

Could you please give me a hand with this?

Upvotes: 2

Views: 442

Answers (1)

Benedikt Kromer
Benedikt Kromer

Reputation: 731

As there is no XML, running example etc. i can't tell you why this error occurs but..

Best practise is to biind also in the detail view the selected entity with expand to the detail and so on

MasterEntitySet->DetailEntitySet

As bindings are propagated to children there is no need to bind the iconTabBar again. Data is already there. Again i don't know your case, but most services look like this

MasterEntitySet->DetailEntitySet->DataVariantA(ForIconTab1)
                                ->DataVariantB(ForIconTab2)
                                ->DataVariantC(ForIconTab3)

In V4 your detail code looks like this

oView.bindObject({
                path: "/MasterEntity(" + this._args.ID + ")",
                parameters: {
                      $expand:`DetailEntityNavPath($expand=DataVariantANavPath()...`
                },
                events: {
                    dataReceived: (oEvent) => {...

Upvotes: 1

Related Questions