TableSelectDialog SAPUI5中的OData绑定

时间:2015-12-09 14:57:15

标签: sapui5

我试图在tableselectdialog上做odata绑定。出于某些原因,我发现很难使用SAP WEB IDE制作片段,因此我没有使用片段进行对话,只是在控制器上创建了对话框。假设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();
}

提前谢谢

1 个答案:

答案 0 :(得分:0)

指定型号" UTIL"组?它是在控件上的视图,组件吗?是通过manifest.json设置还是手动设置?如果手动,请显示确切的...

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

path : "/", 

EntitySet是什么" /"应该是?此外,您正在使用指定的模型" UTIL"在代码的其余部分中,绑定路径中也缺少这些代码。所以我想在你的情况下绑定路径看起来应该是这样的:

path : "UTIL>/MyEntitySet",

当然你必须更换" / MyEntitySet"适合你的情况。这仅适用于" sap / opu / odata / srmnxp / UTIL"是一个命名模型" UTIL"。然而,这个" UTIL"命名模型与" UTIL"无关。在URL字符串" sap / opu / odata / srmnxp / UTIL"。