Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to pass array object to 'items' to sap.ui.commons.DropdownBox in SAPUI5

Hi ,

I am trying to pass array of values to sap.ui.commons.DropdownBox options in SAPUI5 but entire object is displaying in dropdown box.

Below is the code,

dropDownBox: function(dropDownLabel,dropDownItems){

  var dropDownOptions = {dept1:"Dept1",dept2:"Dept2"};

  var dropDownElement = new sap.ui.layout.form.FormElement({

  label : new sap.ui.commons.Label({

  text : dropDownLabel


  fields : [ new sap.ui.commons.DropdownBox("Depts", {

  layoutData : new sap.ui.layout.form.GridElementData({

  hCells : "3"


  items : [new sap.ui.core.ListItem("Deptlist", {

  text : dropDownOptions

  }) ]

  }) ]


return dropDownElement;



Please help me .


Hi Venkatesh,

Check this -

var dropDownOptions = [{dept1:"Dept1",dept2:"Dept2"},{dept1:"Dept11",dept2:"Dept21"}]; //Consider you have an array like this

sap.ui.getCore().getModel().setProperty("/dropDownOptions",dropDownOptions); //Bind the dropDownOptions array to a model

var oItemTemplate = new sap.ui.core.ListItem({text:"{dept1}"});

var oDDBox = new sap.ui.commons.DropdownBox({

    items: {

  path: "/dropDownOptions",

  template: oItemTemplate




Sai Vellanki.

1 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question