【发布时间】:2017-05-23 17:30:10
【问题描述】:
我正在使用 XML 视图在我的 SAPUI5 项目中创建视图。我试图实现工厂函数以用于 sap.ui.Table 控件的列和行。列工厂似乎工作正常,但由于某种原因,行工厂永远不会被执行。
查看:
<Table
id="dataPreviewTbl"
class="data-preview"
columns="{path: 'oModel>/columns', factory: '.colFactory'}"
rows="{path: 'oModel>/rows', factory: '.rowFactory'}" >
</Table>
控制器:
colFactory: function(sId, oContext) {
var sColumnId = oContext.getObject().name;
var multiLabels = [];
multiLabels.push(
new sap.m.Label({
text: sColumnId,
design: "Bold"
})
);
multiLabels.push(
new sap.m.Label({
text: dataType
})
);
return new sap.ui.table.Column({
multiLabels: multiLabels,
sortProperty: sColumnId,
filterProperty: sColumnId,
flexible: false
});
},
rowFactory: function(sId, oContext) {
var cells = [];
for (let i = 0; i < this.colCount; i++) {
cells.push(new sap.m.Text({
"text": "{oModel>" + i + "}"
}));
}
return new sap.ui.table.Row({
"cells": cells
});
}
我已根据特定要求实现了行和列的动态绑定。有人可以在这里建议或帮助我吗?可以让我的头脑思考什么是缺失或错误的。谢谢。
【问题讨论】:
标签: javascript data-binding sapui5