【问题标题】:OData Binding in TableSelectDialog SAPUI5TableSelectDialog SAPUI5 中的 OData 绑定
【发布时间】:2015-12-09 14:57:14
【问题描述】:

我正在尝试在 tableselectdialog 上进行 odata 绑定。由于某些原因,我发现使用 SAP WEB IDE 制作片段很困难,所以我没有为对话框使用片段,只是在控制器上制作了对话框。假设 table 的大部分属性都可以在 tableselectdialog 上看到,我期待我不会遇到任何错误。我能够将我的 odata 绑定在一张桌子上。但是当我实现 tableselectdialog 时,数据绑定似乎不起作用。谁能帮我解决这个错误。下面是我的代码。

组合框使用方法handleAddressType 调用事件按下。我使用的 odata 是 /sap/opu/odata/srmnxp/UTIL

handleAddressType: function(oEvent) {
    alert(oEvent.oSource.getSelectedKey());
    var selectedAddressKey = oEvent.oSource.getSelectedKey();
    var otableSelectDialog = new sap.m.TableSelectDialog("tableSelectD", {
        noDataText: "No Address Found",
        title: "Select Address",
        columns: [
            new sap.m.Column({
                header: new sap.m.Label({
                    text: "AddressNo"
                })
            }),
            new sap.m.Column({
                header: new sap.m.Label({
                    text: "Name"
                })
            }),
            new sap.m.Column({
                header: new sap.m.Label({
                    text: "City"
                })
            }),
            new sap.m.Column({
                header: new sap.m.Label({
                    text: "Country"
                })
            })
        ],
        items: {
            path: "/",
            template: new sap.m.ColumnListItem({
                cells: [
                    new sap.m.Text({
                        text: "{UTIL>AddressNo}"
                    }),
                    new sap.m.Text({
                        text: "{UTIL>Name}"
                    }),
                    new sap.m.Text({
                        text: "{UTIL>City}"
                    }),
                    new sap.m.Text({
                        text: "{UTIL>Country}"
                    })
                ]
            })
        }
    });
    otableSelectDialog.bindAggregation("items", "UTIL>/ShipToAddressCollection?$filter=Addrtype%20eq%20%27" + selectedAddressKey + "%27",
        new sap.m.ColumnListItem({
            cells: [
                new sap.m.Text({
                    text: "{UTIL>AddressNo}"
                }),
                new sap.m.Text({
                    text: "{UTIL>Name}"
                }),
                new sap.m.Text({
                    text: "{UTIL>City}"
                }),
                new sap.m.Text({
                    text: "{UTIL>Country}"
                })
            ]
        }));
    otableSelectDialog.open();
}

提前谢谢你

【问题讨论】:

    标签: sapui5


    【解决方案1】:

    命名模型“UTIL”在哪里设置?它是在视图、组件还是控件上?是通过 manifest.json 设置还是手动设置?如果是手动的,请说明具体如何...

    此外,您的绑定路径看起来有点奇怪:

    path : "/", 
    

    “/”应该是什么实体集?此外,您在其余代码中使用命名模型“UTIL”,绑定路径中也缺少该模型。所以我猜你的绑定路径应该是这样的:

    path : "UTIL>/MyEntitySet",
    

    当然,您必须将“/MyEntitySet”替换为适合您情况的任何内容。这仅在“sap/opu/odata/srmnxp/UTIL”处的服务是命名模型“UTIL”时才有效。但是,这个“UTIL”命名模型与URL字符串“sap/opu/odata/srmnxp/UTIL”中的“UTIL”无关。

    【讨论】:

    • 我的 Util Odata 是在 component.js 中设置的。我假设因为我将绑定路径 viw bindAggregation,所以我将在路径上放置什么并不重要,因为它无论如何都会被替换。
    • 其实在 configuration.js { name: "UTIL", masterCollection: "ShipToAddressCollection", serviceUrl: URI("/sap/opu/odata/srmnxp/UTIL/").directory() , isDefault: false, mockedDataSource: "/srm.shoppingcart.create/model/metadata.xml" },
    • @melai 您可以同时绑定多个模型,这就是您命名它们的原因(在这种情况下为 UTIL)。如果您设置了名称,则必须使用它。否则框架会寻找一个没有名字的模型(全局模型)。
    • @Nabi path: "/" 可以引用仅由对象数组组成的未命名模型(不太可能在 OData 上下文中,但如果您处理纯 JSON,则很有可能)。见jsbin.com/tobifiqoto/2/edit?html,output
    • @Marc I have used changed the path to this UTIL>/ShipToAddressCollection?$filter=Addrtype%20eq%20%27C%27 这是我之前用来绑定表的。假设,如果我也将其用作 TableSelectDialog 的绑定路径,则代码应该获取数据
    猜你喜欢
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 2023-04-11
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多