@helix-x/datagrid-ui - v0.2.0
    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({ scope: 'selected' })}>
    Export selection
    </button>
    )}
    {...rest}
    />
    interface GridApi<T> {
        clearSelection(): void;
        copySelectionToClipboard(): Promise<void>;
        exportCsv(options?: ExportCsvOptions): Promise<void>;
        getDisplayedRows(): T[];
        getFilterModel(): FilterModelMap;
        getRowGroup(): string | null;
        getSelectedIds(): (string | number)[];
        getSelectedRows(): T[];
        getSortModel(): SortModelItem[];
        refresh(options?: { purge?: boolean }): void;
        resetColumns(): void;
        selectAll(): void;
        setFilterModel(model: FilterModelMap): void;
        setRowGroup(colId: string | null): 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 selected rows on the current page to the clipboard as TSV, which spreadsheets expect — or the whole loaded page when nothing on it is selected. Unlike GridApi.exportCsv this never fetches.

      Returns Promise<void>

    • Download rows as CSV, honouring each column's exportValue and suppressExport, with the visible columns in display order.

      By default every row matching the current sort and filters is fetched from the data source — up to 1000 — not just the loaded page. Starting another export cancels one still fetching.

      Parameters

      Returns Promise<void>

      Resolves once the download has been triggered. Rejects if a fetch fails, or with an AbortError when a newer export cancels it.

    • The rows currently loaded for this page, in display order. While grouped, the rows loaded inside expanded groups — never the group rows themselves.

      Returns T[]

    • The column id the grid is grouped by, or null when it is not grouped.

      Returns string | null

    • 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 }

        By default every cached block is dropped first, so nothing stale can survive. Pass purge: false to keep the cached neighbouring pages and re-fetch only the current one.

      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

    • Group by a column, or pass null to ungroup. Ignored for a column without ColumnDef.enableRowGroup. Returns to the first page and collapses every group. Under a controlled rowGroupColId this only asks the owner, through onRowGroupColIdChange.

      Parameters

      • colId: string | null

      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