如何正确处理sapui5中OData Edm.Decimal的数字格式? [英] How to handle number format of OData Edm.Decimal in sapui5 correct?

查看:150
本文介绍了如何正确处理sapui5中OData Edm.Decimal的数字格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来OData会将Edm.Decimal作为"String"发送,其中还包含小数点分隔符.

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

问题:OData应该发送什么?总是相同的值(例如,带."的分隔符)吗?

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

问题:如何通过自动区域设置将这些数据绑定到SAPUI5控件?

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

我已经在使用

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

但是数字始终以点作为分隔符显示.

But numbers are always shown with a dot as separator.

推荐答案

我认为sap.ui.model.type.Float实现中存在错误. 您可以使用该数据类型设置十进制值的格式.

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

但是,如果您尝试更改该值并将其存储回去,则数据将为float类型.但是对于OData,它必须是字符串.

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.

调试方法parserValue给了我提示:

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

如果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.

这篇关于如何正确处理sapui5中OData Edm.Decimal的数字格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆