简体   繁体   English

EDM.Time 的表格列格式

[英]Table column formatting for EDM.Time

I have a table control in linked to a backend OData service.我有一个链接到后端 OData 服务的表控件。 One of the column contains the value "Start time" which is coming from backend as PT01H15M32S .其中一列包含来自后端的值"Start time" ,为PT01H15M32S Is there any way that I can convert this format to the legible format?有什么方法可以将此格式转换为清晰的格式? Below is how I am trying to achieve it.以下是我试图实现它的方式。

oTable.addColumn(new sap.ui.table.Column({
  label: new sap.ui.commons.Label({text: "Start Time"}),
  template: new sap.ui.commons.TextView().bindProperty("text", {
    path: "STRTTIME",
    type: new sap.ui.model.type.Time({
      source: {
        __edmtype: "Edm.Time"
      },
      pattern: "HH:MM:SS"
    })
  }),
  sortProperty: "STRTTIME",
  editable: false,
}));

There is also a function formatValue for sap.ui.model.type.Time , but I am not sure how can I use it to get the correct time format.还有一个用于sap.ui.model.type.Time的函数formatValue ,但我不确定如何使用它来获得正确的时间格式。

By using types you don't need to call formatValue as the runtime will do this for you.通过使用类型,您无需调用 formatValue,因为运行时会为您执行此操作。 However, you should use the correct type: sap.ui.model.odata.type.Time !但是,您应该使用正确的类型: sap.ui.model.odata.type.Time The type you are using does not support EDM data types.您使用的类型不支持 EDM 数据类型。 Also your coding looks strange.你的编码看起来也很奇怪。

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.ui.commons.Label({text: "Start Time"}),
    template: new sap.ui.commons.TextView({
          "text" : { 
              path : "{STRTTIME}",
              type: new sap.ui.model.odata.type.Time({
                  source : { __edmtype: "Edm.Time" }, pattern: "HH:MM:SS" })
              })
           }
    }),
    sortProperty: "STRTTIME",
    editable: false,
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM