I encountered an issue with accessing an array where I stored data from a model read operation. The array, named aData, contains row data for a table and everything seems to be working correctly as all the data is present.
This code snippet is executed after opening a value help dialog, and I intend to populate the table with the retrieved data.
var oTestModel = this.getModel();
oTestModel.read("/shrhelpSet", {
filters: [oFilterObject, oFilterField, oFilterLang],
success: function(oRetrieveResults){
//console.log(oRetrieveResults);
var oDatas2 = oRetrieveResults;
var test1 = oDatas2.results;
var aData = [];
var index = oDatas2.results.length;
var i;
for (i=0; i<index; i++) {
aData.push("{Key: '" + oDatas2.results[i].key + "', Value: '" + oDatas2.results[i].value + "'}");
}
// aData Array
console.log("aData: " + aData);
},
error: function(oError){
console.log(oError);
}
});
The following block of code comes after the model read operation. Here, I have an array containing column data for my table. The oModel2 consists of the column data defined in aColumnData and the rows fetched above are stored in aData. However, there seems to be an issue as it either doesn't return any data or only displays an object. Any tips on handling this better or a solution to this problem?
var aColumnData = [{
columnId: "Key"
}, {
columnId: "Value"
}];
var oModel2 = new sap.ui.model.json.JSONModel();
oModel2.setData({
columns: aColumnData,
rows: aData // THIS IS THE RESULT OF MY MODEL, the results are in aData but i cant access it here
});
oTable.setModel(oModel2);
oTable.bindColumns("/columns", function(index, context) {
var sColumnId = context.getObject().columnId;
return new sap.ui.table.Column({
id : sColumnId,
label: sColumnId,
template: sColumnId
});
});
oTable.bindRows("/rows");