5.0
API
Interfaces
ReactGridProps

ReactGridProps

The ReactGridProps interface defines the properties and callbacks that can be used to configure the ReactGrid component. This interface allows to customize the grid's appearance, behavior, and interactions.

Definition

interface ReactGridProps {
  id?: string;
  styles?: NestedStylesPartial<RGTheme>;
  styledRanges?: StyledRange[];
  rows?: Row[];
  columns?: Column[];
  cells: Cell[];
  onAreaSelected?: (selectedArea: NumericalRange) => void;
  onCellFocused?: (cellLocation: IndexedLocation) => void;
  stickyTopRows?: number;
  stickyRightColumns?: number;
  stickyBottomRows?: number;
  stickyLeftColumns?: number;
  enableColumnSelectionOnFirstRow?: boolean;
  enableRowSelectionOnFirstColumn?: boolean;
  behaviors?: Partial<Record<BehaviorId, Behavior>>;
  initialFocusLocation?: IndexedLocation;
  initialSelectedRange?: Range;
  disableCut?: boolean;
  disableCopy?: boolean;
  disablePaste?: boolean;
  disableFillHandle?: boolean;
  onFocusLocationChanging?: ({ location }: { location: IndexedLocation }) => boolean;
  onFocusLocationChanged?: ({ location }: { location: IndexedLocation }) => void;
  onFillHandle?: (selectedArea: NumericalRange, fillRange: NumericalRange, cellsLookup: CellsLookup) => boolean;
  onCut?: (event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => boolean;
  onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => boolean;
  onPaste?: (event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => boolean;
  onColumnReorder?: (selectedColIndexes: number[], destinationColIdx: number) => void;
  onRowReorder?: (selectedRowIndexes: number[], destinationRowIdx: number) => void;
  onResizeColumn?: (width: number, columnIdx: number[]) => void;
}

Properties

NameTypeDescription
idstringOptional unique identifier for the grid. It should be passed if the useReactGridAPI hook is to be used.
stylesNestedStylesPartial<RGTheme>Optional styles for the grid.
styledRangesStyledRange[]Optional styled ranges within the grid.
rowsRow[]Optional array of rows.
columnsColumn[]Optional array of columns.
cellsCell[]Array of cells.
stickyTopRowsnumberNumber of sticky rows at the top.
stickyRightColumnsnumberNumber of sticky columns on the right.
stickyBottomRowsnumberNumber of sticky rows at the bottom.
stickyLeftColumnsnumberNumber of sticky columns on the left.
enableColumnSelectionOnFirstRowbooleanEnable column selection on the first row.
enableRowSelectionOnFirstColumnbooleanEnable row selection on the first column.
moveRightOnEnterbooleanMoves the focus to the right cell when the Enter key is pressed. By default, it is set to false.
behaviorsPartial<Record<BehaviorId, Behavior>>Optional property that allows to override default ReactGrid behaviors.
initialFocusLocationIndexedLocationInitial focus location in the grid.
initialSelectedRangeRangeInitial selected range in the grid.
disableCutbooleanDisables the cut functionality in the grid.
disableCopybooleanDisables the copy functionality in the grid.
disablePastebooleanDisables the paste functionality in the grid.
disableFillHandlebooleanDisables the fill handle functionality in the grid.

Callbacks

NameTypeDescription
onAreaSelected(selectedArea: NumericalRange) => voidCallback when an area is selected.
onCellFocused(cellLocation: IndexedLocation) => voidCallback when a cell is focused.
onFocusLocationChanging({ location }: { location: IndexedLocation }) => booleanCallback before focus location changes.
onFocusLocationChanged({ location }: { location: IndexedLocation }) => voidCallback after focus location changes.
onFillHandle(selectedArea: NumericalRange, fillRange: NumericalRange, cellsLookup: CellsLookup) => booleanCallback for fill handle action.
onCut(event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => booleanCallback for cut action.
onCopy(event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => booleanCallback for copy action.
onPaste(event: React.ClipboardEvent<HTMLDivElement>, cellsRange: NumericalRange, cellsLookup: CellsLookup) => booleanCallback for paste action.
onColumnReorder(selectedColIndexes: number[], destinationColIdx: number) => voidCallback for column reorder action.
onRowReorder(selectedRowIndexes: number[], destinationRowIdx: number) => voidCallback for row reorder action.
onResizeColumn(width: number, columnIdx: number[]) => voidCallback for column resize action.