alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class UndoRedoAction<T>

    Represents a single action recorded in the Undo/Redo history.

    Inheritance
    object
    UndoRedoAction<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 TypeRelevant Payload Property
    CellEditCellChange
    RowAddRowData, RowIndex, RowPosition
    RowDeleteRowData, RowIndex
    PastePreviousValues
    AutoFillPreviousValues

    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 null, indicating no single-cell edit occurred.

    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
    This property should only be examined when ActionType equals CellEdit. For multi-cell operations like Paste or AutoFill, use PreviousValues instead.

    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 T instances (complete row objects) capturing the state of all affected rows. Each entry in the collection represents one complete row before the multi-row operation was applied. This property is populated for operations affecting multiple rows simultaneously. The default value is null, indicating no multi-row snapshot is required.

    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
    This property complements PreviousValues for scenarios where entire rows must be restored, rather than just individual cell changes. Use this property when row-level state preservation is required. Each element in the collection is a complete data object of type 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 null.

    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
    For example, a paste operation that affects 10 cells will have 10 CellChange<T> entries in this collection, and pressing Ctrl+Z will revert all 10 cells together as a single undo step. Each CellChange<T> within the collection contains complete information for individual cell restoration, including row index, column index, field name, and both old and new values. This property should only be examined when ActionType is Paste or AutoFill.

    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 T instance (a complete row object) that captures the full data state of the affected row. This property is populated only when ActionType is RowAdd or RowDelete. The default value is null.

    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
    This property works in conjunction with RowIndex to uniquely identify and restore the row during undo/redo operations. Always use RowIndex together with 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 null, indicating no specific row is targeted.

    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
    The index is zero-based and refers to the position in the data source, not the visible grid row number. When restoring or redoing, use this value together with RowData to ensure the row is placed in the correct location. This index may shift after sorting, filtering, or grouping operations in subsequent actions.

    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:

    • Top - row was inserted at the beginning
    • Bottom - row was inserted at the end
    This property is set only for RowAdd actions. The default value is null, 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
    This property is only relevant for add operations and should be 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 UndoRedoManager instance. The default value is 0.

    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.

    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved