Can anyone give me a short example of how to add a simple row to a sap.ui.table.Table using JavaScript in Neptune? Let's say I have a table with three columns. My approach was the following:
MyTable.addRow({"COLUMN1":"Text1", "COLUMN2":"Text2", "COLUMN3":"Text3"});
Unfortunately the code doesn't seem to work as my table is staying empty. Also there is no simple example to find on any website. Thank's for any advice.
addRow expects a sap.ui.table.Row as argument.
MyTable.addRow(
new sap.ui.table.Row(sID, oParams)
.addCell(new sap.m.text("foo")
.addCell(new sap.m.text("bar")
);
Finally found the answer. For anyone else, who needs it:
let data;
let model = new sap.ui.model.json.JSONModel();
data = [{
Column1: "Text1",
Column2: "Text2",
Column3: "Text3",
},
];
model.setData({modelData: data});
MyTable.setModel(model).bindRows("/modelData");