@helix-x/datagrid-ui - v0.1.2
    Preparing search index...

    Interface GridApi<T>

    The imperative handle onto a live grid.

    Reach it either through DataGridProps.apiRef or as DataGridProps.toolbar's argument.

    const apiRef = useRef<GridApi<Person>>(null);

    <DataGrid
    apiRef={apiRef}
    toolbar={(api) => (
    <button onClick={() => api.exportCsv({ onlySelected: true })}>
    Export selection
    </button>
    )}
    {...rest}
    />
    interface GridApi<T> {
        clearSelection(): void;
        copySelectionToClipboard(): Promise<void>;
        exportCsv(options?: ExportCsvOptions): void;
        getDisplayedRows(): T[];
        getFilterModel(): FilterModelMap;
        getSelectedIds(): (string | number)[];
        getSelectedRows(): T[];
        getSortModel(): SortModelItem[];
        refresh(options?: { purge?: boolean }): void;
        resetColumns(): void;
        selectAll(): void;
        setFilterModel(model: FilterModelMap): void;
        setSortModel(model: SortModelItem[]): void;
        startEditing(rowId: string | number): void;
        stopEditing(): void;
        updateRows(rows: T[]): void;
    }

    Type Parameters

    • T

      The row type.

    Index
    • Deselect everything.

      Returns void

    • Copy the selection to the clipboard as TSV, which spreadsheets expect.

      Returns Promise<void>

    • The rows currently loaded for this page, in display order.

      Returns T[]

    • Ids of every selected row, including those on other pages.

      Returns (string | number)[]

    • The selected rows that are on the current page.

      Returns T[]

    • Re-fetch the current page.

      Parameters

      • Optionaloptions: { purge?: boolean }

        purge: true drops every cached block first, so nothing stale can survive; otherwise cached neighbouring pages are kept.

      Returns void

    • Discard the user's column layout and return to the definitions' defaults.

      Returns void

    • Select every row on the current page.

      Returns void

    • Open the row editor programmatically.

      Parameters

      • rowId: string | number

        The id, as returned by getRowId.

      Returns void

    • Close the editor, abandoning any uncommitted draft.

      Returns void

    • Patch rows already on screen, matched by getRowId, without a round trip.

      Ids that are not on the current page are ignored, so a live feed can push everything it has without the client filtering first. Scroll position, selection, sort and any open editor are all preserved.

      Parameters

      • rows: T[]

        Whole replacement rows, not partials.

      Returns void