Reputation: 5433
I have a list with items. After a click I want to open a new dialog and bind it to some detail information about the clicked item.
My data source is a SAP HANA database with an OData interface. The interface looks like:
Table/Path: Items
|ID|NAME|PRICE|ITEM_DETAILS (Navigation Property)|
Table/Path: ItemsDetails
|ID|ITEM_ID|...|
The list has a binding to Items
which works fine. On a click, I want to bind my dialog to the navigation property ITEM_DETAILS
but the new binding does not works. The dialog is still binding/showing to the "old" path Items
instead of ItemsDetails
.
The dialog fragment:
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<SelectDialog
id="detailInformation"
noDataText="No data..."
title="{item}">
<StandardListItem
title="{ID}"
description="{FREQUENCY}"
type="Active" />
</SelectDialog>
</core:FragmentDefinition>
The event handler:
if (!this.selectLoadProfile) {
this.selectLoadProfile = sap.ui.xmlfragment(this.getView().getId(), "de.xxx.view.fragment.Dialog", this);
this.getView().addDependent(this.selectLoadProfile);
this.selectLoadProfile.bindElement("ITEM_DETAILS");
}
this.selectLoadProfile.open();
Can someone tell me how I can dynamically load the data?
Upvotes: 0
Views: 4298
Reputation: 5713
One approach is to get the Item path in the Click event handler, and bind ItemDetail path to Dialog.
onClick:function(oEvent) {
var oControl = oEvent.getSource();
var oItemPath = oControl.getBindingContext().getPath();
var oItemDetailPath = oItemPath + "/ITEM_DETAILS";
if (!this.selectLoadProfile) {
this.selectLoadProfile = sap.ui.xmlfragment(this.getView().getId(),
"de.xxx.view.fragment.Dialog", this);
this.getView().addDependent(this.selectLoadProfile);
}
this.selectLoadProfile.bindElement(oItemDetailPath);
this.selectLoadProfile.open();
}
Upvotes: 0
Reputation: 870
Your question is bit confusing me, What i understood from that is You have a List in your view on click of list item a dialog is open that contains the item detail which is a navigation property of the item. Below is the code what you are trying.
this.selectLoadProfile.bindElement("ITEM_DETAILS");
This statement is not specific to which item details you want to bind.so try with below binding path.
this.selectLoadProfile.bindElement("ITEM(id)/ITEM_DETAILS");
As the above statement is in the condition (!this.selectLoadProfile)
make sure that execute every time so that binding of Element should update.
I hope this will work for you.
Upvotes: 0