为什么我的表行到对话框的绑定失败? [英] Why is my table row to dialog binding failing?

查看:62
本文介绍了为什么我的表行到对话框的绑定失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JSView重新创建此示例:

I'm trying to recreate this example using a JSView:

https://embed.plnkr.co/BA9T4Z0QdsZrqkooWTs2/

数据绑定到表,然后单击一行,它将行数据绑定到对话框。

The data is bound to the table, and then when clicking a row, it binds the row data to the dialog box.

我试图在自己的项目中遵循此示例,但无法使其正常工作,因此我尝试了在JSView中逐步重新创建上面的示例。

I was trying to follow this example in my own project, but I could not make it work, so I then tried to recreate the example above step by step in a JSView.

https://embed.plnkr.co/ jvaQyVgvjNP261lVBFaz / (忽略App.view.xml文件)。

https://embed.plnkr.co/jvaQyVgvjNP261lVBFaz/ (ignore the App.view.xml file).

在我的控制器的第34行 getBindingContext( userList) 是不确定的,即使我使用正确的模型名称。

On Line 34 of my controller getBindingContext("userList") is undefined, even though I'm using the correct model name.

这与示例控制器的第31行形成对比,其中 getBindingContext( list)返回一个对象。

This contrasts with Line 31 of the example's controller where getBindingContext("list") returns an object.

我在做什么错了?

推荐答案

在XML示例中,项目按下是在列列表项上设置的,在JS示例中是在表格上设置的。 getSource()然后返回表而不是该行。您可以通过更改新闻事件来解决此问题:

In the XML example, item press is set on the column list item, in the JS example it's set on the table. getSource() then returns the table instead of the line. You can fix it by changing the press event:

var oTable = new sap.m.Table({
    id: "UserTable",
    columns: [
        new sap.m.Column({
            header: new sap.m.Label({
                text: "User ID"
            })
        }),
        new sap.m.Column({
            header: new sap.m.Label({
                text: "Name"
            })
        })          
    ]
});

var template = new sap.m.ColumnListItem({
    type: "Active",
    visible: true,
    press: [oController.onItemPress, oController],
    cells: [
        new sap.m.Text({
            text: "{userList>Userid}"
        }),
        new sap.m.Text({
            text: "{userList>Name}"
        })
    ]
});

这篇关于为什么我的表行到对话框的绑定失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆