Formatter 参数传递为 null
Formatter parameter passes as null
我正在尝试将 table 数据导出到 Excel sheet。没有格式化程序一切正常。但是我必须在将 table 转换为 Excel 之前格式化一些单元格。我正在调试代码。 Formatter 函数的参数作为空值传递。这是我的代码:
var oExport = new sap.ui.core.util.Export({
exportType: new sap.ui.core.util.ExportTypeCSV({
separatorChar: ";"
}),
models: this.getView().getModel(),
rows: {
path: "/FaaliyetServisiSet"
},
columns: [{
name: "Kişi",
template: {
content: "{Klnad}"
}
}, {
name: "Faaliyet",
template: {
content: "{Falyt}"
}
}, {
name: "Süre",
template: {
content: {
parts: ["Sure"],
formatter: function(oValue) { // oValue is null that's the problem !!!!!!!
oValue = oValue + 2;
return oValue;
}
}
}
}, {
name: "Proje",
template: {
content: "{Proje}"
}
},
]
});
对于 parts
,您应该使用对象数组而不是字符串
parts: [
{ path: "Sure" }
]
https://openui5.hana.ondemand.com/#docs/guide/07e4b920f5734fd78fdaa236f26236d8.html
我在一些数据绑定用例中遇到了类似的问题。格式化程序函数使用初始数据绑定值调用,该值可以为 null 或未定义。我通过简单的 null 和 undefined 检查忽略格式化程序函数的调用来规避这个问题。
我正在尝试将 table 数据导出到 Excel sheet。没有格式化程序一切正常。但是我必须在将 table 转换为 Excel 之前格式化一些单元格。我正在调试代码。 Formatter 函数的参数作为空值传递。这是我的代码:
var oExport = new sap.ui.core.util.Export({
exportType: new sap.ui.core.util.ExportTypeCSV({
separatorChar: ";"
}),
models: this.getView().getModel(),
rows: {
path: "/FaaliyetServisiSet"
},
columns: [{
name: "Kişi",
template: {
content: "{Klnad}"
}
}, {
name: "Faaliyet",
template: {
content: "{Falyt}"
}
}, {
name: "Süre",
template: {
content: {
parts: ["Sure"],
formatter: function(oValue) { // oValue is null that's the problem !!!!!!!
oValue = oValue + 2;
return oValue;
}
}
}
}, {
name: "Proje",
template: {
content: "{Proje}"
}
},
]
});
对于 parts
parts: [
{ path: "Sure" }
]
https://openui5.hana.ondemand.com/#docs/guide/07e4b920f5734fd78fdaa236f26236d8.html
我在一些数据绑定用例中遇到了类似的问题。格式化程序函数使用初始数据绑定值调用,该值可以为 null 或未定义。我通过简单的 null 和 undefined 检查忽略格式化程序函数的调用来规避这个问题。