Skip to Content
0
Aug 31, 2019 at 06:58 AM

Combox dropdown data issue in case of named model

659 Views

Hi Experts,

Requirement : These should be a submit button on click of that dialog should open and inside the dialog combo box present with hardcoded data. When I use default model then I am getting right value but in case of named model not able to get data in the combo box. Please find different codes and suggest how can I achieve same with named model as well because in case of real time multiple model has been used to suffice this need this requirement.

XML Code :

<Button
text="Submit"
width="250px"
type="Reject"
press="onRejectDialog"
/>

Controller code :

Default

:

onInit: function () {
var myJSON = {
Data: [{
Reason: "User left the company",

}, {
Name: "Bob",

}, {
Name: "Michael",

},
{
Name: "Steve",

}
]
};
var oModel = new sap.ui.model.json.JSONModel(myJSON);
sap.ui.getCore().setModel(oModel);
sap.ui.getCore().byId("combobox");
},

onRejectDialog: function () {
var oItem = new sap.ui.core.Item("items", {
text: "{Name}"
});
var dialog = new Dialog({
title: 'Reject',
type: 'Message',
content: [

new sap.m.ComboBox('combobox', {
width: '50%',

items: {
path: "/Data",
template: oItem
}
}),


],
beginButton: new Button({
text: 'Reject',
press: function () {
dialog.close();
}
}),
endButton: new Button({
text: 'Cancel',
press: function () {
dialog.close();
}
}),
afterClose: function () {
dialog.destroy();
}
});

dialog.open();
}

Thanks and Regards,

RK