Class UndoRedoAction<T>
Represents a single action recorded in the Undo/Redo history.
Inherited Members
Namespace: Syncfusion.Blazor.Grids
Assembly: Syncfusion.Blazor.Grids.dll
Syntax
public class UndoRedoAction<T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of data in the grid rows that the action targets. |
Remarks
Depending on the ActionType, the relevant payload is stored in a single property:
- CellChange for CellEdit actions.
- RowData and RowIndex for RowAdd and RowDelete actions.
- PreviousValues for Paste and AutoFill actions.
Constructors
UndoRedoAction()
Declaration
public UndoRedoAction()
Properties
ActionType
Gets the kind of grid mutation this action represents in the Undo/Redo history.
Declaration
public UndoRedoActionType ActionType { get; }
Property Value
| Type | Description |
|---|---|
| UndoRedoActionType | One of the UndoRedoActionType enumeration values that identifies the type of grid operation. The default value is None, indicating an uninitialized or empty action. |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording actions. This ensures data integrity and prevents accidental corruption of the undo/redo history.
The ActionType determines which payload properties should be examined:
| Action Type | Relevant Payload Property |
|---|---|
| CellEdit | CellChange |
| RowAdd | RowData, RowIndex, RowPosition |
| RowDelete | RowData, RowIndex |
| Paste | PreviousValues |
| AutoFill | PreviousValues |
CellChange
Gets the cell-level change details captured when a single cell is modified in the grid.
Declaration
public CellChange<T>? CellChange { get; }
Property Value
| Type | Description |
|---|---|
| CellChange<T> | A CellChange<T> instance containing the row index, column index, field name, old value, and new value of the modified cell.
This property is set only when ActionType is CellEdit.
The default value is |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording cell edit actions.
Use this property to access the details of a cell edit action, including:
- The row and column indices that identify the cell location
- The field name that corresponds to the column's data property
- The OldValue (value before edit) for undo operations
- The NewValue (value after edit) for redo operations
- A reference to the GridColumn definition
PreviousRows
Gets the collection of row data snapshots for multi-row actions where multiple rows are affected atomically.
Declaration
public List<T>? PreviousRows { get; }
Property Value
| Type | Description |
|---|---|
| List<T> | A list of |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording multi-row operations.
PreviousRows enables atomic undo/redo for multi-row operations:
- All rows in the collection are treated as a single logical operation
- When undoing, all rows are simultaneously reverted to their stored state
- When redoing, all rows are simultaneously restored to their modified state
T, allowing full row restoration.
This ensures that complex multi-row operations maintain data consistency across the entire action lifecycle.
Always examine ActionType before accessing this property to ensure it applies to the current action.
PreviousValues
Gets the collection of individual cell changes captured during multi-cell batch operations such as paste and autofill.
Declaration
public List<CellChange<T>>? PreviousValues { get; }
Property Value
| Type | Description |
|---|---|
| List<CellChange<T>> | A list of CellChange<T> instances where each entry represents a single affected cell within the multi-cell operation.
Each CellChange<T> contains the cell location, field name, old value, and new value.
This property is set only for Paste and AutoFill actions.
The default value is |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording multi-cell batch operations such as paste and autofill.
PreviousValues enables atomic undo/redo for multi-cell operations:
- All cells in the collection are treated as a single logical operation
- When undoing, all cells in the collection are simultaneously reverted to their previous values
- When redoing, all cells in the collection are simultaneously reapplied with their new values
RowData
Gets a snapshot of the row data representing the complete state of a row during add or delete operations.
Declaration
public T? RowData { get; }
Property Value
| Type | Description |
|---|---|
| T | A |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording row add or row delete actions.
RowData contains a snapshot of the entire row object at the time the action was recorded:
- For RowAdd actions, it stores the new row data that was inserted
- For RowDelete actions, it stores the deleted row data, allowing it to be restored during undo
RowData to ensure proper row placement and restoration.
For multi-row operations, consider using PreviousRows instead.
RowIndex
Gets the zero-based index of the row that is targeted by row-level actions such as add or delete operations.
Declaration
public int? RowIndex { get; }
Property Value
| Type | Description |
|---|---|
| int? | A nullable integer representing the zero-based index of the affected row within the current grid data source.
This property is populated for RowAdd and RowDelete actions.
The default value is |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording row operations.
The row index identifies the position in the underlying data source where a row was added, deleted, or modified:
- For RowAdd, it indicates the position where the row was inserted
- For RowDelete, it indicates the position from which the row was removed
RowPosition
Gets the relative insertion position (top or bottom) where a new row was added to the grid.
Declaration
public NewRowPosition? RowPosition { get; }
Property Value
| Type | Description |
|---|---|
| NewRowPosition? | A NewRowPosition enumeration value indicating the insertion position relative to the grid's data: This property is set only for RowAdd actions. The default value isnull, indicating no row position was recorded.
|
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording row add actions.
RowPosition is used in conjunction with RowIndex and RowData to properly restore added rows:
- When undoing an add operation, this value helps determine the correct restoration strategy
- When redoing an add operation, it ensures the row is inserted in the same relative position
null for delete or cell edit actions.
Always examine this value in conjunction with RowIndex to accurately reconstruct row additions.
SequenceNumber
Gets a monotonically increasing sequence number assigned when the action is recorded by the UndoRedoManager.
Declaration
public int SequenceNumber { get; }
Property Value
| Type | Description |
|---|---|
| int | An integer that uniquely and sequentially identifies this action within the lifetime of the grid's |
Remarks
This property is read-only from external code. Only the UndoRedoManager<T> can set this value when recording actions.
The sequence number starts at 1 and increments by 1 for each action recorded, providing a temporal ordering of operations. This value is primarily used for internal diagnostics, debugging, and action ordering rather than for direct public consumption. Developers can use this value to correlate actions across multiple operations or to implement custom tracking mechanisms. The sequence number remains constant throughout the lifetime of the action and is never reused.