Skip to Content

Error while using addRow() method in sap.ui.table.Table

Hi Experts,

I have a requirement where i have to add rows to a Table(sap.ui.table.Table) dynamically on click of a button.

In the press event of a button i used table.AddRow() method , but it is showing me following error---

sap-ui-core.js:160 2017-08-10 17:50:47.754465 The control manages the rows aggregation. The method "addRow" cannot be used programmatically! - Element sap.ui.table.Table#tb1 I am attaching my code as well as screenshot of error message i recieved.


sap.ui.jsview("addrow.addRow", {

	/** Specifies the Controller belonging to this View. 
	* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
	* @memberOf addrow.addRow
	getControllerName : function() {
		return "addrow.addRow";

	/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed. 
	* Since the Controller is given to this method, its event handlers can be attached right away. 
	* @memberOf addrow.addRow
	createContent : function(oController) {
var oModel = new sap.ui.model.odata.ODataModel("proxy/http/");

		var oInput = new sap.m.Text("as",{text:"{OrderID}"});

		var m = [];	
	//	alert(oModel.getProperty("/Orders(10248)/OrderID"));
		var req = [];
		req.Company_Name = sap.ui.getCore().byId("as");
	var	tbl1 = new sap.ui.table.Table("tb1",{
			new sap.ui.table.Row("r1",{
				       new sap.m.Label("first",{text:"row1"}),
				       new sap.m.Text("fifgst",{text:"row1"})

						       new sap.m.Label("firssdt",{text:"row2"}),
						       new sap.m.Text("firsdfest",{text:"row2"})

								       new sap.m.Label("firewersdgfst",{text:"row3"}),
								       new sap.m.Text("firsssgrett",{text:"row3"})


		btn1 = new sap.m.Button("btn",{
				tbl1.addRow(new sap.ui.table.Row("r5",{
					       new sap.m.Label("firsdfgrrer45t",{text:"row1"}),
					       new sap.m.Text("fir45st",{text:"row1"})

							       new sap.m.Label("fi4rst",{text:"row2"}),
							       new sap.m.Text("fi45rst",{text:"row2"})

									       new sap.m.Label("fir45gst",{text:"row3"}),
									       new sap.m.Text("firsfgt",{text:"row3"})
	return new sap.m.Page({
			title: "Title",
			content: [


Thanks and RegardsAman Anand

error-message.png (13.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 10, 2017 at 02:33 PM

    You are adding the fields through the JS code programmatically with the use of aggregation. To add rows, you need to use data binding.

    Use a model(json) and bind the model to the table. Create entries in the model and those many rows will appear int eh table.

    If you need to add a row, create one entry in the model and refresh the table, it will reflect a new entry.

    Check this thread:



    Add comment
    10|10000 characters needed characters exceeded

  • Nov 19, 2018 at 09:18 AM

    Hi Sharath M G , I am trying to do as you said, but the new record is not visible in a table after using createEntry method. Maybe because my model is OData model? oEvent.getSource().getParent().getParent() is sap.ui.table.Table component.

    var oEntry = this.getModel().createEntry(oEvent.getSource().getParent().getParent().getBinding().getPath());
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 19, 2018 at 12:50 PM

    if you want to add a row without saving and show it in table directly, you need to use jsonmodel.

    you cannot do that with odatamodel.

    Add comment
    10|10000 characters needed characters exceeded