通过对话框绑定动态数据



我有一个带有项目的列表。单击后,我想打开一个新的对话框,并将其绑定到有关点击项目的一些详细信息。

我的数据源是带有ODATA接口的SAP HANA数据库。界面看起来像:

Table/Path: Items
|ID|NAME|PRICE|ITEM_DETAILS (Navigation Property)|
Table/Path: ItemsDetails
|ID|ITEM_ID|...|

该列表具有与Items的绑定,可以正常工作。单击,我想将对话框绑定到导航属性ITEM_DETAILS,但新的绑定行不通。对话框仍具有绑定/显示到"旧"路径Items而不是ItemsDetails

对话框片段:

<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>

活动处理程序:

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();

有人可以告诉我如何动态加载数据吗?

您的问题使我感到困惑,我从中了解到您在单击列表项目的视图中有一个列表,其中一个对话框打开,其中包含项目详细信息,该详细信息是导航属性项目。以下是您正在尝试的代码。

this.selectLoadProfile.bindElement("ITEM_DETAILS");

此语句并非特定于您要绑定的项目详细信息。因此,请尝试以下绑定路径。

this.selectLoadProfile.bindElement("ITEM(id)/ITEM_DETAILS");

由于上述语句处于条件(!this.selectLoadProfile)处,请确保每次执行执行,以使元素的绑定应更新。

我希望这对您有用。

一种方法是在单击事件处理程序中获取项目路径,并将itemDetail路径绑定到对话框。

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();
}

最新更新