on 12-11-2014 7:13 AM
Hi All,
I am having two set of odata response which I am retrieving through oModel.Read.
testarray[0] = oData;
testarray[1] = oData;
After this the the generated array of objects is converting to an object like this
var rg = {};
for (var i = 0; i < testarray.length; ++i)
{
rg[i] = testarray[i];
}
Setting a model:
var singleRowModel = new sap.ui.model.json.JSONModel({});
var oTable = new sap.ui.table.Table("oTable");
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Rate Category"}),template: new sap.ui.commons.TextView({text: "{RateCategory}"})}));
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Net Amount"}),template: new sap.ui.commons.TextView({text: "{NetAmount}"})}));
oTable.setModel(singleRowModel, "singleRowModel");
singleRowModel.setData(rg);
oTable.bindRows("singleRowModel");
Now i can see in the console the defined oTable is loaded with the singleRowModel with odata as two Objects which i got from the odata response earlier.
singleRowModel
oTable
But while displaying I am not getting empty table, Can anyone please help where is the issue?
Regards,
Arun
Try that
var oTable = new sap.ui.table.Table("oTable");
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Rate Category"}),
template: new sap.ui.commons.TextView({text: "{singleRowModel>RateCategory}"})}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Net Amount"}),
template: new sap.ui.commons.TextView({text: "{singleRowModel>NetAmount}"})}));
oTable.bindRows("singleRowModel>/");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kai Helferich,
I tried that but still the table is showing no Data....But i could see from the console the Omodel is added in the Table as in the screenshot which i shared with my question.
singleRowModel: F , I have a doubt normally it will be some constructor, but here inside table it is coming as F
Regards,
Arun
Hi Arun,
see working sample here: JS Bin
Second mistake you have done:
var rg = {}; //Value / Key Array
=>
var rg = []; //Simple Array
What's the difference?
Read this: JavaScript Arrays: The Difference Between [] and { }
kind regards
Kai
Hi Kai Helferich,
Thanks for the example.
Finally I got the solution...
The error was in setting up the model for the table,
I approached as below:
singleRowModel.setData({items:testarray});
oTable.setModel(singleRowModel, "singleRowModel");
// oTable.bindRows("singleRowModel>/items");
oTable.bindItems("singleRowModel>/items", oRow);
Now it is working perfectly fine.
Regards,
Arun
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.