[英]SAPUI5 Data binding for table not working
I am new into SAPUI5 development, and i have problems with data binding in a table.我是 SAPUI5 开发的新手,我在表中绑定数据时遇到问题。 In my other tables it works but this one is strange.
在我的其他表中它有效,但这个很奇怪。
I am opening a value helper dialog, and want to display some data in the table.我正在打开一个值助手对话框,并希望在表中显示一些数据。
My current code is:我目前的代码是:
//
oTable = this._oValueHelpDialog.getTable();
oTable.setModel(this.getModel());
oTable.setModel(oCol, "columns");
// bind aggregation
// items
// shrhelpSet
// spalten heißen key und value
var oTemplate = new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
text: "{key}"
}),
new sap.m.Text({
text: "{value}"
})]
});
oTable.bindAggregation("items", "/shrhelpSet", oTemplate);
My console says "Aggregation "items" does not exist in Element sap.ui.table.Table#__table0" and when i am using a another binding method for example oTable.bindItems() or bindRows() it is saying that the method is undefinded or cannot be found.我的控制台说“元素 sap.ui.table.Table#__table0 中不存在聚合“项目”,当我使用另一种绑定方法时,例如 oTable.bindItems() 或 bindRows() 是说该方法是未定义或无法找到。 i am suprised that i have this problem in the value helper, in my other tables i have no problems with data binding.
我很惊讶我在值助手中有这个问题,在我的其他表中我没有数据绑定问题。
The sap.m.Table has the aggregation "items", but in your case the table is a " sap.ui.table.Table " which uses the aggregation "rows". sap.m.Table 有聚合“items”,但在你的情况下,表是一个“ sap.ui.table.Table ”,它使用聚合“行”。 That is also the reason why the other methods don't work.
这也是其他方法不起作用的原因。
"ColumnListItem" won't work neither because the aggregation needs " sap.ui.table.Row ". “ColumnListItem”也不起作用,因为聚合需要“ sap.ui.table.Row ”。
For databinding, have a look at the example(s) for the grid table .对于数据绑定,请查看网格表的示例。
This worked for me and solved my problem这对我有用并解决了我的问题
var aColumnData = [{
columnId: "Key"
}, {
columnId: "Value"
}];
var aData = [{
Key: "asdf",
Value: "hey"
}, {
Key: "abcd",
Value: "hey2"
}];
var oModel2 = new sap.ui.model.json.JSONModel();
oModel2.setData({
columns: aColumnData,
rows: aData
});
oTable.setModel(oModel2);
oTable.bindColumns("/columns", function(index, context) {
var sColumnId = context.getObject().columnId;
//alert(sColumnId);
return new sap.ui.table.Column({
id : sColumnId,
label: sColumnId,
template: sColumnId
});
});
oTable.bindRows("/rows");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.