JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE HTML>
<script src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons,sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script>
sap.ui.localResources("combo");
var view = sap.ui.view({id:"idsample1", viewName:"combo.sample", type:sap.ui.core.mvc.ViewType.JS});
view.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
JavaScript
oDataEmpTypes = {
items : [ {"emptype" : "001" , "text" : "Employee" },
{"emptype" : "002" , "text" : "Contractor" }
]
};
var oEmpTypesModel = new sap.ui.model.json.JSONModel(oDataEmpTypes);
var listitem = new sap.ui.core.ListItem();
listitem.bindProperty("key", "emptype").bindProperty("text","text");
var lv_result_set_path = "/items";
var oListResultSet = new sap.ui.commons.ListBox();
oListResultSet.setModel(oEmpTypesModel);
oListResultSet.bindAggregation("items", lv_result_set_path, listitem);
var oResultSetDD = new sap.ui.commons.DropdownBox("ResultSetDD1",
{ tooltip:"emptype",
displaySecondaryValues:true,
"association:listBox" : oListResultSet,
value:"" ,
change : function(oEvt){
var selectedEmpType = oEvt.getParameter("selectedItem");
var empType = selectedEmpType.getKey();
alert(empType);
}
});
oResultSetDD.placeAt("content");