Created
December 21, 2015 03:56
-
-
Save TimoStaudinger/8eee60dc3d37146bba3d to your computer and use it in GitHub Desktop.
SAPUI5 Data Formatting Showcase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' /> | |
<title>SAPUI5 Data Formatting Showcase</title> | |
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m,sap.ui.layout" data-sap-ui-xx-bindingSyntax="complex" data-sap-ui-theme="sap_bluecrystal"></script> | |
<script type="text/javascript"> | |
var model = new sap.ui.model.json.JSONModel({ | |
threshold: 100000, | |
amounts: [ | |
50000, | |
100000.999, | |
30000.1234, | |
150000, | |
70000.678, | |
35000, | |
110000.1, | |
1200, | |
60000, | |
61234 | |
], | |
currency: 'USD' | |
}); | |
var thresholdInput = new sap.ui.layout.VerticalLayout({ | |
content: [ | |
new sap.m.Label({ | |
text: 'Threshold' | |
}), | |
new sap.m.Input({ | |
value: { | |
path: '/threshold', | |
type: 'sap.ui.model.type.Float', | |
formatOptions: { | |
maxFractionDigits: 2, | |
minFractionDigits: 2 | |
} | |
}, | |
width: '200px' | |
}) | |
] | |
}) | |
var list = new sap.m.List({ | |
headerText: "Formatted", | |
items: { | |
path: "/amounts", | |
template: new sap.m.CustomListItem({ | |
content: [ | |
new sap.m.ObjectStatus({ | |
text: { | |
parts: [{ | |
path: '' | |
}, { | |
path: '/currency' | |
}], | |
type: 'sap.ui.model.type.Currency' | |
}, | |
state: { | |
parts: [{ | |
path: '' | |
}, { | |
path: '/threshold' | |
}], | |
formatter: function(amount, threshold) { | |
return amount >= threshold ? 'Error' : 'Success' | |
} | |
} | |
}).addStyleClass('sapUiSmallMarginBegin sapUiSmallMarginTopBottom') | |
] | |
}) | |
} | |
}); | |
var source = new sap.m.List({ | |
headerText: "Source data", | |
items: { | |
path: "/amounts", | |
template: new sap.m.StandardListItem({ | |
title: '{}' | |
}) | |
} | |
}); | |
var page = new sap.m.Page({ | |
showHeader: false, | |
content: [thresholdInput, list, source] | |
}); | |
var app = new sap.m.App({ | |
pages: [page] | |
}).placeAt("content"); | |
app.setModel(model); | |
</script> | |
</head> | |
<body id="content" class="sapUiBody"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment