0
votes

I've got a problem in my (SAP)UI5 application. It occurs when opening the first item in a list in the Master view.

The flow is like this:

  • User clicks on item
  • handleClick function is calling an oData service to lock the item in the database
  • A callback with the nav.to("Detail") function is handed to the lock function
  • When the lock was successful, the callback is executed
  • Now, the onNavigation event is triggered where we use bindElement to expand the line items data of the detail view, which is omitted in the master
  • When the detail is rendered everything appears to be fine, but very shortly after it finishes the screen flashes and the detail is rendered again
  • This time the line items are duplicated as seen in the following screen

Master/Detail view after clicking on first item in Master view list

I also use a formatter for the dates, and the dates are not shown. I learned that the formatter is called twice. The value handed to the formatter is empty after the first call and contains the date after the second call.

I think that's related to the same issue, but I'm not sure yet.

The master is bound to the base service url in the Component.js, with appView.setModel(dataModel);. In the onNavigation function of the detail controller, the following code is used:

onNavigation: function(context) {
    this.getView().bindElement({
        path: context.sPath,
        parameters: {
            select: "Id,Lifnam,Rmwwr,Waers,Sendedatum,Workflowtyp,Sktodat,Stufe,MonFrgstA,Bukrs,Belnr,Gjahr,EdcObject,BstatTxt",
            expand: "Positions"
        }
    });
},

The table in the detail view is starting like this:

    <Table
        headerText="{i18n>LineItemTableHeader}"
        items="{Positions}" >
        <columns>
            <Column>

And the rendering error is only happening for the first item in the master list, but not for every item either. And I'm not able to find any meaningful connection between the items, that could describe this error.

The oData service doesn't look corrupted: oData in the binding context

I would be happy about any hint what could go wrong here. Thank you in advance.

Edit: Together with a colleague I just learned that it could have to do with the $count variable which is used by the oData service.

Here a screenshot of the Network tab of the dev tools:

Chrome network tab with oData calls

The $count value is not bound to the positions here, instead it's connected to the number of items in the master list. I guess that should be the problem, but I'm still waiting of confirmation from my team mate.

1

1 Answers

1
votes

We found the problem. As mentioned in my edit above, it's been the $count value, which was not computed correctly on back-end side.

Here the result for $count before the fix: Network tab with count before fixing it

And here the result for $count after fixing the oData/RFC side: Network tab after fixing it

The UI asked for a count of the positions, but got the count of the items in the master view list. When the number of items in the list is smaller than the number of line items, it had to do two requests to receive the data. The line items were already here though, which resulted in the duplication of the shown line items.