2016-03-17 89 views
-2

我有一个表格控件链接到后端OData服务。其中一列包含起始时间值,后者来自后端PT01H15M32S(xsd格式)。有什么办法可以将这种XSD格式转换为清晰的HH:MM:SS格式。以下是我如何努力实现它。EDM的表格列格式化。时间

oTable.addColumn(new sap.ui.table.Column({ 
     label: new sap.ui.commons.Label({text: "Start Time"}), 
     //template: new sap.ui.commons.TextView ({text : "{STRTTIME}"}), 
     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, 
    })); 

还有一个功能formatValue新sap.ui.model.type.Time,但我不知道我怎么可以用它来获得正确的时间格式。

回答

0

通过使用类型,您不需要调用formatValue,因为运行时会为您执行此操作。但是,您应该使用正确的类型:sap.ui.model.odata.type.Time!您使用的类型不支持EDM数据类型。你的编码看起来很奇怪。

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, 
})); 
+0

感谢您突出显示不正确的类型。我对此很新,我无法正确使用类型:new sap.ui.model.type.Time.formatValue。 – Manpreet