0
votes

Today I faced a strange issue (could be a silly one) for data binding while navigating to 2nd view which is showing List of data coming from OData model and Panel at the bottom

I have replicate the code into this link - http://plnkr.co/edit/ClZqvo?p=info (You can run this as well through RUN on the Top) - Kindly run it in chrome with disabled security (Due to CORS issue)

Now the problem is when I am navigating to 2nd view (OData Table) and then Select any List Item, you will see in the bottom, the Panel will reflect the selected item (as I have used BindElement method to bind the path). After this I clicked back and then my 1st view will appear (JSON table) again I clicked on Next Button and then 2nd view will appear again. When I select the same item which I have selected previously then this time Panel will not show the selected items. This issue is coming only when I navigate back and forth and select the same item. Not able to understand what caused this?

But if I choose any other item then it will show me the selected item.

Anyone having any idea about this?

~Rahul

1

1 Answers

0
votes

This is common issue when using bindElement, I have faced it too. It might be failing to resolve context of referenced entity. So, fields are not binded with respective values.

As a alternative you can use setBindingContext to bind fields within panel.

Since you are using named model, it should be specified as argument to setBindingContext.

So your code will be like

onSelect: function(oEvent) {
    var oContext = oEvent.getSource().getBindingContext("odataModel");
    var oProductDetailPanel = this.getView().byId("prodDetailsPanel");
    oProductDetailPanel.setBindingContext(oContext, "odataModel");
}