SAPUI5表组合框:无法显示所选项目的说明

时间:2018-04-30 20:01:21

标签: sapui5

这可能很容易,但作为一个新人,我有点困惑。

我有一个绑定到DB表A(未命名模型)的SAPUI5表(sap.ui.table.Table)。组合框使用selectedKey属性绑定到表中相应字段的值,并将项模板绑定到表B(名为model:f4,表A中字段的文本所在的位置),请参阅下面的代码:

*this.oRoleTable.addColumn(new sap.ui.table.Column({

label: new sap.m.Label({text: "Agreement Role ID"}),

template: new sap.m.ComboBox({

id: "cbRoleType",

selectedKey: "{AgrRoletpid}",

items: { path: "f4>/Role_TypesSet",

template: oRoleItemTemplate,

templateShareable: "false"} })

}));*

正如您在下面的快照中看到的那样,selectedKey属性看起来不起作用 - 出于测试原因,附加的最后一列保存了与所选键对应的值,在本例中为{AgrRoletpid}

Combo error 1

对所选键值没有填充感到沮丧。尝试了一个我发现的技巧,它看起来像对控件的附加绑定,是上面语句的补充

*this.oRoleTable.addColumn(new sap.ui.table.Column({

label: new sap.m.Label({text: "Agreement Role ID"}),

template: new sap.m.ComboBox({

id: "cbRoleType",

selectedKey: "{AgrRoletpid}",

items: { path: "f4>/Role_TypesSet",

template: oRoleItemTemplate,

templateShareable: "false"} }).bindProperty("value", "AgrRoletpid")

}));*

现在发生了一些事情,但并不是我所期待的。实际值显示在组合中,问题是,我应该看到描述(检查图像2),而不是值。现在,而不是文字"角色1"选中,我有它的键(301 =角色1)

Combo error 2

从上面可以明显看出,我所要做的就是显示来自表B的文本,并将键绑定到表A的值以保存值。应该很简单,但似乎我在这里遗漏了一些东西,任何帮助???

致以最诚挚的问候,

格雷格(疯了)

@Andrii Naumovych:项目模板代码:

            var oRoleItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrRoletpId}", text:"{f4>AgrRoletptxt}"});  

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Agreement ID"}),
            template: new sap.m.Text({text: "{AgrRoleid}"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Agreement Role ID"}),
            template: new sap.m.ComboBox({ 
                                id: "cbRoleType", 
                                selectedKey: "{AgrRoletpid}",
                                //selectedItemId: "{AgrRoletptxt}",
                                items: {
                                    path: "f4>/Role_TypesSet",
                                    template: oRoleItemTemplate,
                                    templateShareable: "false"}
                    }).bindProperty("value", "AgrRoletpid") 
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Valid From"}),
            template: new sap.m.Text({text: "{ path: 'ValidFrom', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Valid To"}),
            template: new sap.m.Text({text: "{ path: 'ValidTo', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Staff Type ID"}),
            template: new sap.m.Text({text: "{StaffTypeid}"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Staff ID"}),
            template: new sap.m.Text({text: "{StaffId}"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "First Name"}),
            template: new sap.m.Text({text: "{FirstName}"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "Last Name"}),
            template: new sap.m.Text({text: "{LastName}"})
            }));

            this.oRoleTable.addColumn(new sap.ui.table.Column({
            label: new sap.m.Label({text: "TEST"}),
            template: new sap.m.Text({text: "{AgrRoletpid}"})
            }));

0 个答案:

没有答案