Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Keyed vs Non-Keyed Root JSON Element
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<script id="sap-ui-bootstrap"
type="text/javascript"
src="/sapui5/latest/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-xx-bindingSyntax="complex">
</script>
<script id="view1" type="sapui5/xmlview">
<mvc:View
controllerName="local.controller"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<MultiComboBox
id="mcb"
placeholder="Please choose one or more categories"
items="{/}">
<core:Item
key="{Category}"
text="{CategoryName}" />
</MultiComboBox>
</mvc:View>
</script>
<script>
sap.ui.controller("local.controller", {
onInit : function(oEvent) {
var sURL = "/sapui5/latest/test-resources/sap/m/demokit/cart/model/ProductCategory.json";
var oModel = new sap.ui.model.json.JSONModel(sURL);
this.getView().setModel(oModel);
}
});
var oView = sap.ui.xmlview({ viewContent: jQuery('#view1').html() });
oView.placeAt("content");
</script>
</head>
<body class="sapUiBody" id="content" />
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<script id="sap-ui-bootstrap"
type="text/javascript"
src="/sapui5/latest/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-xx-bindingSyntax="complex">
</script>
<script id="view1" type="sapui5/xmlview">
<mvc:View
controllerName="local.controller"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<MultiComboBox
id="mcb"
placeholder="Please choose one or more categories"
items="{/ProductCategories}">
<core:Item
key="{Category}"
text="{CategoryName}" />
</MultiComboBox>
</mvc:View>
</script>
<script>
sap.ui.controller("local.controller", {
onInit : function(oEvent) {
var sURL = "/sapui5/latest/test-resources/sap/m/demokit/cart/model/ProductCategory.json";
var oModel = new sap.ui.model.json.JSONModel(sURL);
oModel.attachEventOnce('requestCompleted', function(oEvent) {
var oModel = oEvent.getSource();
oModel.setData({
"ProductCategories" : oModel.getData()
});
});
this.getView().setModel(oModel);
}
});
var oView = sap.ui.xmlview({ viewContent: jQuery('#view1').html() });
oView.placeAt("content");
</script>
</head>
<body class="sapUiBody" id="content" />
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment