GridCommand API

Definition

#[non_exhaustive]
pub enum GridCommand { /* 47 variants */ }

All mutations to GridState go through state.apply(GridCommand).

All variants

Selection

SelectCell(CellCoord)
ExtendSelection(CellCoord)
ClearSelection
MoveSelection { delta_row: i64, delta_col: i64, extend: bool }
SelectRow(u64)
ExtendRowSelection(u64)
SelectCol(usize)
ExtendColSelection(usize)

Row checkboxes

ToggleRowChecked(u64)          // logical row index — click on the checkbox column
ToggleAllFilteredChecked       // toggles all rows passing the active filter (or all rows, if unfiltered)
SetShowCheckboxColumn(bool)    // show/hide the row-selection checkbox column
SetCheckboxColumnWidth(f64)    // width in logical px (checkbox stays centered — controls the margin too)
Note

Checked state (GridState.checked_rows) is tracked separately from SelectionState, keyed by physical row id so it survives sort/filter changes. See Selection for the full model.

Scrolling & Viewport

ScrollTo { x: f64, y: f64 }
ScrollBy { dx: f64, dy: f64 }
Resize { width: f64, height: f64 }

Columns

ResizeColumn { col_idx: usize, new_width: f64 }
CommitColumnResize { col_idx: usize, old_width: f64, old_flex: Option<f64> }
AutoFitColumn {
    col_idx: usize, char_width: f64,
    header_char_width: f64, cell_padding: f64, header_right_reserve: f64,
}
AutoFitAllColumns {
    char_width: f64, header_char_width: f64,
    cell_padding: f64, header_right_reserve: f64,
}
MoveColumn { from_idx: usize, to_idx: usize }
SetPinnedColumnCount { count: usize }
Note

CommitColumnResize records the old size for undo history. For programmatic resizing use ResizeColumn directly.

Sorting & Filtering

ToggleSort { col_key: String }               // cycles asc → desc → off
SetSort { col_key: String, dir: SortDir }    // explicit direction
ClearSort
SetColumnFilter { col_key: String, text: String }
ClearAllFilters

Editing

StartEdit { row: u64, col_key: String }
ValidateEdit { value: String }
CommitEdit { row: u64, col_key: String, value: String }
CancelEdit
SetInvalidEditMode(InvalidEditMode)
ClearCells   // Delete/Backspace — clears selected cells, no clipboard
Note

ValidateEdit re-checks the in-progress edit's pending value without committing — a no-op without an active edit, and it creates no undo entry. rs-grid-web dispatches it on every keystroke for live feedback. See Validation for ValidationRule and InvalidEditMode.

Clipboard

CopySelection
CutSelection
PasteAt { text: String }
Search { query: String }
SearchNext
SearchPrev
ClearSearch

Undo / Redo

Undo
Redo

Display

SetHeaderHeight(f64)
SetRowHeight(f64)
SetShowHeader(bool)
SetShowRowNumbers(bool)
SetHoveredRow(Option<u64>)

Server-side data

NotifyPageLoaded       // signal that a page fetch completed
SetTotalRowCount(u64)  // update total row count in server-side mode

Behaviour toggles

SetEditable(bool)          // global inline-edit on/off
SetSelectable(bool)        // global selection on/off (clears selection when false)
SetColumnReorderable(bool) // header drag-to-reorder on/off (MoveColumn unaffected)

CommandOutput

#[non_exhaustive]
pub enum CommandOutput {
    None,
    CopyText(String),
    CopyError(CopyError),
    ValidationError { row: u64, col_key: String, message: String },
    PasteApplied { cells: Vec<CellCoord> },
    CellsCleared { cells: Vec<CellCoord> },
}

#[non_exhaustive]
pub enum CopyError {
    NoSelection,
    TooManyRows,
}
CommandOutput
CopySelectionCopyText(tsv) or CopyError
CutSelectionCopyText(tsv) or CopyError
CommitEdit (rejected)ValidationError { row, col_key, message } — fires for both InvalidEditMode::Revert and ::Block
PasteAtPasteApplied { cells } — coordinates actually written, a subset of the target rectangle (locked/invalid cells are skipped)
ClearCellsCellsCleared { cells } — coordinates actually cleared, a subset of the selection; not emitted if nothing was cleared
All othersNone

PasteApplied/CellsCleared's cells is what rs-grid-web passes to its success-flash animation, instead of the full selection/target rectangle — see Selection & Clipboard.