我的简单表格如下:
<f:SimpleForm layout="ResponsiveGridLayout">
<f:content>
<m:Select id="Employee" items="{Employee>/EmployeeList}" change="onEmployeechange">
<c:Item key="{Employee>key}" text="{Employee>value}" />
<m:layoutData>
<l:GridData span="L2 M2 S2"/>
</m:layoutData>
</m:Select>
</f:content>
</f:SimpleForm>
我将从后端获取雇员列表的位置(即,雇员姓名)。当我们从下拉列表中选择任何一个雇员姓名时,将打开一个对话框,我的控制器如下:
onEmployeechange:function(){
this.oDialog = new sap.m.Dialog({
title: "EmployeeList",
contentWidth: "40px",
contentHeight: "300px",
content: [
new sap.m.Text({ width: "100%", text: "Employee Name" }),// here i want to get the selected employee name from the simple form as text in dialog box
new sap.m.Text({ width: "100%", text: "City" }),
new sap.m.FlexBox({
justifyContent: "Center",
items: [
new sap.m.Select("cityId", {
width: "60%",
items: {
path: '/Employee/City',
template: new sap.ui.core.Item({
key: '{key}',
text: '{value}'
})
}
})
]
}),
],
}
添加了oEvent参数后,您就可以访问选定的值,甚至可以访问键(如果需要)。我认为这是您的要求。请说明这是否不是您所需要的。
onEmployeechange: function(oEvent) {
this.oDialog = new sap.m.Dialog({
title: "EmployeeList",
contentWidth: "40px",
contentHeight: "300px",
content: [
new sap.m.Text({
width: "100%",
text: oEvent.getSource().getSelectedItem().getName();
}),
new sap.m.Text({
width: "100%",
text: "City"
}),
new sap.m.FlexBox({
justifyContent: "Center",
items: [
new sap.m.Select("cityId", {
width: "60%",
items: {
path: '/Employee/City',
template: new sap.ui.core.Item({
key: '{key}',
text: '{value}'
})
}
})
]
}),
],
}