:: Home >>

addRow

Adds the new row to the grid.

addRow() method inserts the index of the new row at the end of the row indices array and adds the row html to the display without full grid refresh.

addRow() method does not add the row to the datasource - you should first add the row to the datasource and then update the grid with addRow(index) passing the index of the new row as an argument.

This method triggers onRowAdding and onRowAdded events.

Syntax

obj.addRow(index);

Parameters

index (string/number) - index of the new row in the datasource

Examples

var myData = [
    ["row 0", 0]
]

var obj = new AW.UI.Grid;
obj.setCellData(myData);
obj.setColumnCount(2);
obj.setRowCount(1);
document.write(obj);

function addRow(){
    // calc new row index
    var i = myData.length;

    // add row to the datasource
    myData[i] = ["row " + i, i];

    // update grid
    obj.addRow(i);
}

Remarks

Currently it is not possible to insert the new row in the middle of the grid - it is always added as a last row.

See also

deleteRow method, row indices property, row events

Comments

29 Jan 08
Data in all added rows is same Amit Joshi (3)
12 Jul 07
addRow without change of scroll position Volker Niepel (4)
4 Apr 07
Auto Resize a row - version 2.0.1 (1)
22 Sep 06
Bug in addRow() if datasource was empty Robin (2)
20 Sep 06
Behavior when editing, adding records - not friendly like MS Access or Excel? Ron (3)
9 Mar 06
inserting Rows Chris Angus (3)
7 Mar 06
Insert a row below current selected one Yevaud (3)
Add row for XML Tobias (1)
23 Feb 06
No vertical scrollbar after adding rows Jose Luis (Spain) (3)
21 Feb 06
Cannot add/delete Bryan Smith (0)

Comments will appear on this page and in the main forum.

Documentation:

Recent changes:

2.5.0 - 2.5.2
2.5.2
2.5, 2.5.1
2.5.1
2.5
Release History
2.5
2.0.2
textToValue
textToData