Documentation

@kanunilabs/datagrid-react


@kanunilabs/datagrid-react / DataSource

Interface: DataSource<TRow>

Type Parameters

TRow

TRow = GridRowData

Methods

byKey()?

optional byKey(key): Promise<TRow | undefined>

Parameters

key

RowKey

Returns

Promise<TRow | undefined>


exportRows()?

optional exportRows(request, signal): AsyncIterable<TRow[]>

The rows of a STREAMED export (exportToCsv({ stream: true }), exportToExcel({ stream: true })), in pieces, in the order the file should hold them — the source's own way to hand over a large result: a server cursor, a streamed HTTP response, an export endpoint.

Optional: without it the grid pages through load with remote.exportPageSize. The request carries the grid's sort, filter and quick search; signal aborts when the user cancels (stop reading then). The file is written only once every piece has arrived: a failed or cancelled stream leaves no file behind.

Parameters

request

ExportRowsRequest

signal

AbortSignal

Returns

AsyncIterable<TRow[]>


load()

load(options): Promise<LoadResult<TRow>>

Parameters

options

LoadOptions

Returns

Promise<LoadResult<TRow>>


loadDistinctValues()?

optional loadDistinctValues(options): Promise<DistinctValuesPage | DistinctValue[]>

Distinct values of one column, for the header filter popup.

OPTIONAL, and the popup is offered only when it is implemented: a grid that holds a few cached blocks of a server-side table cannot derive this itself, and a checklist built from "whatever happens to be cached" is worse than no checklist — the user would tick four values believing they were all of them.

Deliberately NOT given the current filter. The client-side implementation computes distinct values over the FULL column precisely so that unticking a value never makes it vanish from the list; narrowing them server-side would make the two behave differently for no stated reason.

Parameters

options

DistinctValuesOptions

Returns

Promise<DistinctValuesPage | DistinctValue[]>