首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在其他对象[TimePicker]中绑定对象[表]中的数据

如何在其他对象[TimePicker]中绑定对象[表]中的数据
EN

Stack Overflow用户
提问于 2017-08-31 02:23:31
回答 1查看 65关注 0票数 0

我有问题,需要对两个对象使用一个模型。但我不知道该怎么做。在综合中,我有一个模型(modelJSON),在这个模型中,我将它与我的" table “对象链接起来,但与此同时,我需要在表中显示(逐行),我也以同样的方式将数据链接到我的时间选择器.

目前,它不工作,因为它没有列出时间选择器的数据,而是表的数据。

其结果是:

代码语言:javascript
复制
--------------
Turno | Time |
------|------|
T1    |      |
      |      |
T2    |      |
      |      |
T3    |      |

这就是我需要的..。

代码语言:javascript
复制
----------------------
Turno |     Time      |
------|---------------|
T1    | 01:00   14:00 |
      |               |  
T2    | 01:00   08:00 |
      |               |
T3    | 07:59   23:00 |

我的代码:

代码语言:javascript
复制
var modelJSON =  
            [
                {ID_TURNO : "T1",  H1 : '01:00', H2 : '14:00' },
                {ID_TURNO : "T2",  H1 : '05:59', H2 : '08:00' },
                {ID_TURNO : "T3",  H1 : '07:59', H2 : '23:00' }
            ];

    var oSection =
        new sap.uxap.ObjectPageSection({
                title: "Week " + targetWeek,
                subSections: new sap.uxap.ObjectPageSubSection({
                            blocks: 
                                new sap.ui.table.Table({
                                    width: "98%",
                                    selectionMode: sap.ui.table.SelectionMode.Single,
                                    visibleRowCountMode: sap.ui.table.VisibleRowCountMode.Fixed,
                                    visibleRowCount: 2,
                                    rowSelectionChange: function(oEvent) {

                                        var path = oEvent.getParameter("rowContext").getPath();
                                        var oData = this.getModel().getProperty(path);

                                    },
                                    columns: [
                                        new sap.ui.table.Column({
                                            label: new sap.ui.commons.Label({ text: "Turno" }),
                                            template: new sap.ui.commons.TextView({ text: "{ID_TURNO}" }),
                                            width: '33px'
                                        }),
                                        new sap.ui.table.Column({
                                            label: new sap.ui.commons.Label({ 
                                                textAlign : "Center",
                                                text: "Time"
                                            }),
                                            template: new sap.ui.layout.form.Form({
                                                layout: new sap.ui.layout.form.ResponsiveGridLayout({
                                                breakpointL : 140
                                                }),
                                                formContainers: [
                                                    new sap.ui.layout.form.FormContainer({
                                                        formElements: [
                                                            new sap.ui.layout.form.FormElement({
                                                                fields: [new sap.m.TimePicker({
                                                                        valueFormat : "HH:mm",
                                                                        displayFormat : "HH:mm",
                                                                        placeholder : " ",
                                                                        width : "62px",
                                                                        value : "{H1}"
                                                                    }).addStyleClass("sapUiSizeCompact")
                                                                    ]
                                                            })
                                                        ]
                                                    }),
                                                    new sap.ui.layout.form.FormContainer({
                                                        formElements: [
                                                            new sap.ui.layout.form.FormElement({
                                                                fields: [new sap.m.TimePicker({
                                                                        valueFormat : "HH:mm",
                                                                        displayFormat : "HH:mm",
                                                                        placeholder : " ",
                                                                        width : "62px",
                                                                        value : "{H2}"
                                                                    }).addStyleClass("sapUiSizeCompact")
                                                                ]
                                                            })
                                                        ]
                                                    })
                                                ]    
                                            }),
                                            width: '95px',
                                            hAlign : "Center"
                                    })
                                    ]
                                }).setModel(new sap.ui.model.json.JSONModel(modelJSON))
                                .bindRows({ path: "/" })
                                .setVisibleRowCount(modelJSON.length)
                            })
                    });

谢谢!:)

EN

回答 1

Stack Overflow用户

发布于 2017-08-31 09:02:36

您可以使用VBox控件示例,而不是使用表单:

代码语言:javascript
复制
 template: new sap.m.VBox({
    content: [new sap.m.TimePicker({                                                                        
                valueFormat : "HH:mm",                                                                        
                displayFormat : "HH:mm",                                                                        
                placeholder : " ",                                                                        
                width : "62px ",                                                                        
                value : "{H1}"                                                                    
            }).addStyleClass("sapUiSizeCompact"),
         new sap.m.TimePicker({
             valueFormat : "HH:mm",
             displayFormat : "HH:mm",
             placeholder : " ", 
             width : "62px",
             value : "{H2}"                                                
         }).addStyleClass("sapUiSizeCompact")
]
});


                                                            ]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45972283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档