如何"刷新"表中行中的数据?我知道,当模型发生变化时,表会被刷新。但问题是,这些行是由工厂方法创建的。行的代码如下所示:
formatter : function(text, id) {
if (text != null && id != null) {
if (this.getProperty("showId")) {
return text + " ( " + id + " )";
} else {
return text;
}
}
return "";
因此,当我点击"隐藏ID"按钮时,属性会发生更改,应该刷新表,以便构建新的内容。我该怎么做?我检查了方法.refresh()
,但这不起作用。
编辑:这是我的工厂功能专栏:
columns : [ new sap.ui.table.Column({
label : "XYZ( ID )",
filterProperty : "SHORT_TEXT",
template : new sap.m.Label().bindProperty("text", {
parts : [ {
path : "SHORT_TEXT",
type : new sap.ui.model.type.String()
}, {
path : "ID",
type : new sap.ui.model.type.String()
} ],
formatter : function(text, id) {
if (text != null && id != null) {
if (this.getProperty("showId")) {
return text + " ( " + id + " )";
} else {
return text;
}
}
return "";
}.bind(this)
})
})
这就是改变属性的方法:
onShowHideIdRequest : function(oControlEvent) {
if (oControlEvent.getParameter("pressed")) {
this.setProperty("showId", true);
sap.ui.getCore().byId("oShowHideIdButton").setIcon("sap-icon://show");
} else {
this.setProperty("showId", false);
sap.ui.getCore().byId("oShowHideIdButton").setIcon("sap-icon://hide");
}
sap.ui.getCore().byId("oTreeTable").rerender();
},
属性在我的组件中是这样的:
metadata : {
properties : {
showId : {
type : "boolean",
defaultValue : true
}
},
"oTreeTable"ID指的是sap.ui.tableTreeTable
我想了几天这一切都很好,我不知道有什么错。。。
首先,您编写的方法是格式化程序,而不是工厂方法。格式化程序和工厂方法之间存在差异。Formatter用于根据某些条件或评估返回ui5控件的属性值,其中作为工厂方法用于绑定聚合