注:本博客是针对SAPUI5中JS视图的应用,
本博客将对表列定义和绑定以及SAPUI5有用。这将解释如何在运行时使用来自Webservice或oData服务的数据格式化表单元格,因为有时无法配置所需的值以从DB流出来。
让我们以一个来自Webservice的JSON响应为例,什么叫物联网,
{"JSON":[{"A":34,"B":56,"C":78},
{"A":20,"B":90,"C":45},
{"A":10,购返利,"B":20,"C":87}};
现在我想按原样显示表中的前两列,但第三列应该是来自模型的第二列和第三列的减法,
var JSON={"JSON":[{"A":34,"B":56,"C":78},
{"A":20,"B":90,"C":45},
{"A":10,"B":20,"C":87};
var oModel=newsap.ui.model模型.json.JSONModel文件();
oModel.setData设置数据(JSON);
var oTableproduct1=新建sap.ui.table表.Table();
oTableLastReading.addColumn文件(新建)sap.ui.table表.Column().setTemplate(新建)sap.ui.commons.TextView().bindProperty("text",{parts:[{path:"'A'"}]}).setLabel(新建)sap.ui.commons.Label({text:"A"}));
oTableLastReading.addColumn文件(新建)sap.ui.table表.Column().setTemplate(新建)sap.ui.commons.TextView().bindProperty("text",返现卡,{parts:[{path:"'B'"}]}).setLabel(新建)sap.ui.commons.Label({text:"B"}));
oTableLastReading.addColumn文件(新建)sap.ui.table表.Column().setTemplate(新建)sap.ui.commons.TextView().bindProperty("文本",{parts:[{path:"'B'"},返利是什么意思,{路径:"'C'"}],格式化程序:函数(B,C){
var=B-C返回值;}})).setLabel(新)sap.ui.commons.Label({text:"C"}));
如上所示,企业开发软件,"formatter"函数可与"binproperty"聚合一起用于在运行时格式化任何列元素。