Я предполагаю, что ваши данные JSONModel примерно такие:
var oEmployee = {
"EmployeeList": [{
"key": "ram",
"value": "ram"
}, {
"key": "raj",
"value": "raj"
}, {
"key": "rani",
"value": "rani"
}],
"City": [{
"key": "BS",
"value": "Brescia"
}, {
"key": "BG",
"value": "Bergamo"
}]
};
Итак, ваш диалог должен быть:
onEmployeechange: function (oEvent) {
var sPath = oEvent.getParameter("selectedItem").getBindingContext("Employee").getPath();
if (!this.oDialog) {
this.oDialog = new sap.m.Dialog({
title: "EmployeeList",
contentWidth: "40px",
contentHeight: "300px",
content: [
new sap.m.Text({
width: "100%",
text: {
path: "Employee>value"
}
}),
new sap.m.Text({
width: "100%",
text: "City"
}),
new sap.m.FlexBox({
justifyContent: "Center",
items: [
new sap.m.Select("cityId", {
width: "100%",
items: {
path: "/City",
model: "Employee",
template: new sap.ui.core.Item({
key: "{Employee>key}",
text: "{Employee>value}"
})
}
})
]
})
],
beginButton: new sap.m.Button({
type: sap.m.ButtonType.Emphasized,
text: "OK",
press: function () {
this.oDialog.close();
}.bind(this)
}),
endButton: new sap.m.Button({
text: "Close",
press: function () {
this.oDialog.close();
}.bind(this)
})
});
this.getView().addDependent(this.oDialog);
}
this.oDialog.bindElement({ path: sPath, model: "Employee" });
this.oDialog.open();
},
Некоторые подсказки:
- Используйте определение AMD для своих модулей (в данном случае
Text
, Button
и Dialog
) - Повторное использование
Dialog
- Для сложных диалогов предпочтите XML фрагменты свыше js или добавьте свой диалог как зависимый в XML непосредственно
- Использование
bindElement
РЕДАКТИРОВАТЬ Результат