DataEditorRef

The data editor ref allows imperative interaction with the data editor.

export interface DataEditorRef {
    appendRow: (col: number, openOverlay?: boolean) => Promise<void>;
    updateCells: (cells: DamageUpdateList) => void;
    getBounds: (col?: number, row?: number) => Rectangle | undefined;
    focus: () => void;
    emit: (eventName: EmitEvents) => Promise<void>;
    scrollTo: (
        col: number | { amount: number; unit: "cell" | "px" },
        row: number | { amount: number; unit: "cell" | "px" },
        dir?: "horizontal" | "vertical" | "both",
        paddingX?: number,
        paddingY?: number,
        options?: {
            hAlign?: "start" | "center" | "end";
            vAlign?: "start" | "center" | "end";
        }
    ) => void;
    remeasureColumns: (cols: CompactSelection) => void;
}

appendRow

Appends a row to the data grid.


emit

Emits the event into the data grid as if the user had pressed the keyboard shortcut.


focus

Causes the data grid to become focused.


getBounds

getBounds returns the current bounding box of a cell. This does not need to be a currently rendered cell. If called with col and row as undefined, the bounding box of the entire data grid scroll area is returned.


remeasureColumns

remeasureColumns causes the columns in the selection to have their natural sizes recomputed and re-emitted as a resize event. This is useful if data has changed and it is desireable to force auto-columns to recompute their sizes.

πŸ’‘ This is fairly expensive and will cause slowdowns if called frequently.


scrollTo

Requests the data grid to scroll to a particular location. If only one direction is requested it will get as close as it can without scrolling the off axis. Padding can be applied to inset the cell by a certain amount.


updateCells

Example usage:

Causes the data grid to rerender these specific cells. Rerendering a single cell is significantly faster than invalidating the getCellContent callback as in the latter case all cells must be redrawn.

Last updated

Was this helpful?