Hi,
In my app I have an overview page for "Customer" where different entities / entitysets from an OData service will be used to display information like Partner roles, Contacts, Attachments and so on.
Unfortunately this entities can't be connected to each other via navigation.
My data model looks something like this:
ShipTo(Key = Kunnr)
Contacts
Attachments
CustomerSalesData (Key = Kunnr, Vkorg, Vtweg, Spart)
PartnerRoles
The indented entities can be reached via navigation from the parent entity
On my page I have an icon tab bar to arrange all this information on the page.
The binding context for the entire page is the ShipTo entity.
Then I set different binding contexts for the icon tab filters where necessary.
For example: The tab filter for Partnerroles has a binding context to a CustomerSalesData entity.
In that tab filter content area I have a sap.m.Table with items aggregation = "{PartnerRoles}".
PartnerRoles is a navigation property of the CustomerSalesData entity and will retrieve all partner roles of the customer.
When navigating to the page I create all binding contexts and assign them to the tab filters.
The binding context for the ShipTo entity is bound to the view itself (because in the page title I need data from that entity).
Problem: It seems that - independent of how I order the statements in my coding - the framework generates an OData request to GET ShipTo('XXX')/PartnerRoles which fails because PartnerRoles is no navigation property of ShipTo.
It seems that despite I have set a separate binding context for the tab filter which contains the table, the relative binding "{PartnerRoles}" is associated to the view's context and not to the tab filter's context.
After that the correct call for GET CustomerSalesDataSet(......)/PartnerRoles is placed and succeeds.
Can someone explain this behavior or suggest a workaround?
Another strange thing is: If I explicitly bind the same entity to each of my 3 tab filters via
oTabFilter1.bindElement("/CustomerSalesDataSet("'......'"); oTabFilter2.bindElement("/CustomerSalesDataSet("'......'"); oTabFilter3.bindElement("/CustomerSalesDataSet("'......'");
The framework triggers the same OData GET request 3 times.
I think the framework should realize that the entity has already been loaded (or at least requested) into the model and don't execute any further GET requests.
Is this because the OData GET request are asynchronous and when the bindElement calls are executed the data is not yet loaded into the model?
If so, how can I avoid that?
This is the coding for assinging the binding contexts:
_setBindings : function() { var oView = this.getView(); var oITB = oView.byId("ITBCustomer"); var oITBCust = oView.byId("ITBCustomer-Cust"); var aITBCustItems = oITBCust.getItems(); var oModel = this.getView().getModel(); var sPath = ""; var mCustTabs = {}; //oView.bindElement("/ShipToSet('" + this._sKunwe + "')"); for (var i = 0; i < aITBCustItems.length; i++) { mCustTabs[aITBCustItems[i].getKey()] = aITBCustItems[i]; } // Create all necessary binding contexts sPath = "/CustomerSalesDataSet(Kunnr='{0}',Vkorg='{1}',Vtweg='{2}',Spart='{3}')".format(this._sKunnr, this._sVkorg, this._sVtweg, this._sSpart); oModel.createBindingContext(sPath, null, {}, function(context) { // Tab: Customer -> Partners mCustTabs.CustPartners.setBindingContext(context); // Tab: Customer -> Sales mCustTabs.CustSales.setBindingContext(context); }); sPath = "/ShipToSet('{0}')".format(this._sKunwe); oModel.createBindingContext(sPath, null, {}, function(context) { // Entire view oView.setBindingContext(context); // Tab: Customer -> Overview mCustTabs.CustOverview.setBindingContext(context); // Tab: Customer -> General mCustTabs.CustGeneral.setBindingContext(context); // Tab: Customer -> Contacts mCustTabs.CustContacts.setBindingContext(context); // Tab: Customer -> Attachments mCustTabs.CustAttachments.setBindingContext(context); });
}