Add, remove, and reorder grid rows
Add, remove, and reorder grid rows
Technologies > Software Engineering Techniques > Advanced Techniques > Add, Remove, and Reorder Grid Rows
In some cases, you may wish to edit the visible grid without making actual changes to the data in the data source.
For example, one may display additional rows in a grid. Create a new row record and add the record to the grid by calling
addGridRow()
. Pass a value specifying the row index for the added row. In the following case, a value of 0 inserts the new row at the top of the grid. If no row index is specified, the record is added after the final row:
var record = new Ab.data.Record({
'rm.bl_id': 'Building 1031',
'rm.fl_id': '78',
'rm.rm_id': 'Apache'
});
this.prgGridAddRemove_roomGrid.addGridRow(record, 0);
this.prgGridAddRemove_roomGrid.update();
Remove a row record by calling
removeGridRow()
and passing the row index for the record to be removed:
this.prgGridAddRemove_roomGrid.
removeGridRow
(row.getIndex());
this.prgGridAddRemove_roomGrid.update();
Reorder the grid rows by calling
moveGridRow()
and passing the old and new row indices for the record:
this.prgGridAddRemove_roomGrid.moveGridRow(row.getIndex(), row.getIndex() - 1);
this.prgGridAddRemove_roomGrid.update();
Note that simply calling
addGridRow
or
removeGridRow
will not alter the data in the data source, which must be accomplished separately by calling
saveRecord
or
deleteRecord
.
See also: