Skip to content

Commit 15fad96

Browse files
committed
hcpps - adding formatter
1 parent 9344335 commit 15fad96

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • tutorials/hcpps-sapui5-ps-forecast-synchronous/predictive/webapp/model
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
sap.ui.define([
2+
"sap/ui/core/format/NumberFormat"
3+
], function() {
4+
"use strict";
5+
var isNumeric = function(oValue) {
6+
var tmp = oValue && oValue.toString();
7+
return !jQuery.isArray(oValue) && (tmp - parseFloat(tmp) + 1) >= 0;
8+
};
9+
jQuery.sap.require("sap.ui.core.format.NumberFormat");
10+
var oNumberFormat = sap.ui.core.format.NumberFormat.getFloatInstance({
11+
maxFractionDigits: 2,
12+
groupingEnabled: true,
13+
groupingSeparator: ",",
14+
decimalSeparator: "."
15+
}, sap.ui.getCore().getConfiguration().getLocale());
16+
17+
var round = function(value, decimal) {
18+
if (value !== 'undefined' && isNumeric(value)) {
19+
// return Number(value).toFixed(decimal);
20+
return oNumberFormat.format(value);
21+
} else {
22+
return "nothing";
23+
}
24+
};
25+
return {
26+
round: function(value) {
27+
return round(value);
28+
}
29+
};
30+
});

0 commit comments

Comments
 (0)