Sapui5 如何在sap Ui5中添加组合框事件
我在一个表中使用组合框,该表有两个字段,一个是男性字段,另一个是女性字段,如果我将该值更改为存储在JSON模型数据中..如何对其使用事件 下面是我的代码Sapui5 如何在sap Ui5中添加组合框事件,sapui5,Sapui5,我在一个表中使用组合框,该表有两个字段,一个是男性字段,另一个是女性字段,如果我将该值更改为存储在JSON模型数据中..如何对其使用事件 下面是我的代码 oTable.addColumn(new sap.ui.table.Column( { label: new sap.ui.commons.Label({text: "Gender"}), template: new sap.ui.commons.ComboBox(
oTable.addColumn(new sap.ui.table.Column( {
label: new sap.ui.commons.Label({text: "Gender"}),
template: new sap.ui.commons.ComboBox(
{items: [new sap.ui.core.ListItem({text: "Female"}),
new sap.ui.core.ListItem({text: "Male"})]}).bindProperty("value","gender"),
sortProperty: "gender",
filterProperty: "gender",
enabled : true,
change: function(oEvent){
sap.ui.getCore().byId("gender").setValue(oEvent.oSource.getSelectedItemId());
},
width: "75px"
}));
function change(oEvent){
var bEnabled = oEvent.getParameter("enabled");
// modify the enabled property value in the model to reflect changes
oModel.setData({enabled: bEnabled}, true); // true means merge the data instead of replacing
};
但它并没有反映值。请更正代码
您应该将'change'函数移动到组合框中,该组合框当前附加到没有类似事件的列。
您可以将“bindProperty”-调用放入构造函数
在事件函数中,您必须获取模型并更改其值。
我使用了提供的代码,但没有反映更改..如果我在tablecombo框中更改,那么如果我刷新,然后在添加事件后再次显示以前的值..我是SAP UiI5的初学者
new sap.ui.commons.ComboBox({
value: "{gender}",
items: [
new sap.ui.core.ListItem({
text: "Female"
}), new sap.ui.core.ListItem({
text: "Male"
})
],
change: function(oEvent) {
var newValue = oEvent.getParameter("newValue");
var bindingPath = this.getBindingPath("value");
this.getModel().setProperty(bindingPath, newValue);
}
})