row status
RealGrid can manage the state of rows. You can check whether this row is an edited row, an added row, a deleted row, or a row that was added and then deleted. In order to manage the state of a row, the checkStates property value among the properties of dataProviderOptions must be set to true. The default value is true, so no special settings are required.
RealGrid automatically manages row status based on user actions (add, modify, delete). RealGrid can also manage row states arbitrarily according to the developer's intent.
Types of RowState
none
: A state that does not change after being loaded.
created
: Status of the newly added row.
updated
: The value of one or more fields has changed since it was loaded. The created
row will not change to updated
when its value changes.
deleted
: Status of a row that has been deleted after being loaded.
createAndDeleted
: The status of the row that was added and then deleted.
The state deleted
or createAndDeleted
can only be had if the value of dataProvider.options.softDeleting is true . If softDeleting = false, when deleting a row, it is immediately deleted from the dataProvider without changing the row status.
Changing row status by user input
The status of the row can be changed by modifying the value displayed in the grid or by entering the key below.
Ctrl
+ Del
(windows), ctrl
+ fn
+ backspace
(mac): Delete current line or selected lines.
Ins
: Insert a row at the current position
Down Arrow
: Add row from last row
Changing row status by API
You can change the state of a row using dataProvider.setRowState, dataProvider.setRowStates.
Row Status
var curr = gridView.getCurrent();
var state = $(':radio[name="rbRowState"]:checked').val();
dataProvider.setRowState(curr.dataRow, state, true);
var dataRows = gridView.getCheckedRows();
var state = $(':radio[name="rbRowState"]:checked').val();
dataProvider.setRowStates(dataRows, state, true);
Get row number by row status
Get an array of row numbers of rows with status.
var rows = null;
var state = $(':radio[name="rbRowStateArray"]:checked').val();
if (!state || state == "all") {
rows = dataProvider.getAllStateRows(); // RowState.NONE is not included.
} else {
rows = dataProvider.getStateRows(state);
}
alert(JSON.stringify(rows));
Get number of changed rows
Get the number of rows with status.
var state = $(':radio[name="rbRowStateCount"]:checked').val();
var count = dataProvider.getRowStateCount(state);
alert(count);