:: Home >>

deleteRow

Deletes the row from the grid.

deleteRow() method does not delete the row from the datasource, it removes the row index from the row indices array and updates the display without full grid refresh.

This method triggers onRowDeleting and onRowDeleted events.

Syntax

obj.deleteRow(index);

Parameters

index (string/number) - row index

Examples

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

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

function deleteRow(){
    // get the last row index
    var i = obj.getRowCount() - 1;

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

Remarks

When using deleteRow() do not delete the row from the datasource. You should somehow mark the row as deleted, but you should not physically remove the row from the data array or XML object. This is important because removing the row changes (shifts) the indices of the remaining rows and it would break the display. You can restore the display with a full grid refresh but using deleteRow() method allows to avoid full refresh if the row indices stay the same.

See also

addRow method, row indices property, row events

Comments

23 Apr 08
how to delete a first row rafi (1)
24 Sep 07
Bug in example? Rob L (1)
18 Jul 07
Issue with deleteRow Mark Elrod (0)
8 Aug 06
Adding/Deleting Rows (1)
1 May 06
how to delete row from sorted grid Adam Zielinski (4)

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

Documentation:

Recent changes:

2.5, 2.5.1
2.5.1
2.5
Release History
2.5
2.0.2
textToValue
textToData
dataToValue
dataToText