How to handle number format of OData Edm.Decimal in sapui5 correct?

南笙酒味 提交于 2019-12-11 16:42:06

问题


It looks like OData sends Edm.Decimal as "String" also containing the decimal separator.

Question: What should be send by OData? Always the same values (for example separator with ".")?

Question: How can this data be bound to SAPUI5 control with an automatic locale handling?

I am already using

new sap.ui.model.resource.ResourceModel({

But numbers are always shown with a dot as separator.


回答1:


I think there is a bug in sap.ui.model.type.Float implementation. You can use that data type to format decimal values.

But if you try to change the value and store it back, data will be of type float. But for OData it must be a String.

Debugging the method parserValue gives me the hint:

case "string":
    iResult = this.oFormat.parse(oValue);
    ... error handling ...
    return iResult;

The iResult will not be transformed to a String if it is not already a string. You can override that method and ensure that it will return a string.



来源:https://stackoverflow.com/questions/27547654/how-to-handle-number-format-of-odata-edm-decimal-in-sapui5-correct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!