从 listItems 调用动态 Table 值 Onselect

Call Dynamic Table values Onselect from listItems

我想知道是否可以从 listItems 中获取动态 table 值 onSelect。

controller.js

onPress : function(oEvent){
            var oSelectedItem = oEvent.getSource();
            var oContext = oSelectedItem.getBindingContext("invoice");
            var sPath = oContext.getPath();
            var oListItem= this.getView().byId("BoM"); 
                oListItem.bindItems({
                          path : "invoice>/ProductHeadSet('12345')/ProductHead2BOM",
                         template : new sap.m.ColumnListItem({
                             cells: [
                                 new sap.m.Text({
                                     text: "{invoice>Material}"
                                 }),
                                 new sap.m.Text({
                                     text: "{invoice>Component}"
                                 }),
                                 new sap.m.Text({
                                     text: "{invoice>Brand}"
                                 })
                                 ]
                         })
                });
    }

});

上面是我的控制器,当我按下 onPress 时,我可以收到来自“12345”的值。但是,当我尝试通过删除 (12345)"invoice>/ProductHeadSet/ProductHead2BOM"” 来创建动态 onPress 时。它会抛出这样的错误 "The request URI is invalid. The ProductHeadSet segment refers to an entity set and not to a single entity".

感谢和问候。

你的答案就在那里

"The request URI is invalid. The ProductHeadSet segment refers to an entity set and not to a single entity".

在下面的代码中,括号内的数字有助于确定数组中的哪个索引应绑定到列表。
invoice>/ProductHeadSet('12345')/ProductHead2BOM
没有数字,您正试图将整个数组绑定到 oListItem。

编辑
如果没有看到模型和绑定,这有点难以回答,但不是做
path : "invoice>/ProductHeadSet('12345')/ProductHead2BOM"

path : "invoice>"+sPath+"/ProductHead2BOM"