on 08-13-2015 8:22 AM
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;
}
Output:
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
}
});
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Venkatesh
There are 2 ways to do this.
1. http://jsbin.com/bavoja/edit?js,output (use model like about Santhosh has suggested)
2. http://jsbin.com/tonemu/edit?js,output (use model - assuming that your data come in as a map, you need to convert it to array)
Hope this helps
Thanks
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
items : [new sap.ui.core.ListItem("Deptlist", {
text:'{dept1}',
and bind dropdown items with"dropDownOptions ".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.