getContextByIndex不返回所有列

问题描述 投票:1回答:2

我有以下代码

oTableEntry = this.getView().byId("oTable");
var count = oTableEntry._getRowCount();
var oTData;

for (var i = 0; i < count; i++) {
    oTData = oTableEntry.getContextByIndex(i).getObject();

oTData不包含所有列的值,即使它们出现在表中。我在这里做错了吗?

sapui5 binding-context
2个回答
2
投票

希望您正在寻找相同的解决方案!

var oTable = sap.ui.getCore().byId("YourTableID");
if (oTable) {
 var oColumns = oTable.getColumns();//get all columnms
 var oRows = oTable.getItems();
 for (var r in  oRows) {
    var oRow = oRows[r];
    console.log(oRow.getBindingContext().getObject());//return the row data
 }
}

2
投票

我想你正在尝试获取每一行的表列及其值。以下是如何执行此操作的方法:

var oTable = this.getView().byId("oTable");//Get the table by Id    
var aItems = oTable.getAggregation("items");//get the items of the table
for (var i=0; i<aItems.length; i++) {
  var tableColumns = aItems[i].getAggregation("cells");     //Here tableColumns will    //have all the columns of the table rows. 
  var column1Value = tableColumns[1].getProperty("text");
}
© www.soinside.com 2019 - 2024. All rights reserved.