Skip to content

ServerSideDataSource

Since v2.0.0

Unified data source contract for server-side data loading.

Implement getRows to supply root-level rows from a remote API, database, or any asynchronous provider. The grid calls getRows() whenever it needs a new block of rows (on initial load, scroll, sort change, or filter change).

getRows may return either a Promise (e.g. fetch(url, { signal }).then(...)) or a Subscribable (e.g. an Angular HttpClient observable). With a Subscribable, the grid unsubscribes on supersede, which natively cancels the underlying request — no need to wire params.signal into anything.

Optionally implement getChildRows for on-demand child data (tree children, group rows, detail panels, etc.). If child data is already embedded in parent rows (e.g. tree nodes with inline children arrays), this method is not needed.

// Promise / fetch
const dataSource: ServerSideDataSource = {
async getRows(params) {
const res = await fetch(`/api/data?start=${params.startNode}&end=${params.endNode}`, {
signal: params.signal,
});
const data = await res.json();
return { rows: data.items, totalNodeCount: data.total };
},
};
// Angular HttpClient (Observable)
const dataSource: ServerSideDataSource = {
getRows: (params) =>
this.http
.get<{ items: unknown[]; total: number }>('/api/data', { params: toHttpParams(params) })
.pipe(map((d) => ({ rows: d.items, totalNodeCount: d.total }))),
};

Fetch a page/block of root-level nodes. Called on initial load and on scroll/page events.

Before calling this, ServerSide queries loaded plugins for their current state (sort model, filter model, etc.) and passes it through in the params.

Return either a Promise<GetRowsResult> or a Subscribable (Observable). For Subscribables, unsubscription on supersede is what cancels the underlying request.

getRows(params: GetRowsParams): Promise<GetRowsResult<TRow>> | Subscribable<GetRowsResult<TRow>>
NameTypeDescription
paramsGetRowsParams

Fetch child rows for a parent context. Called when a plugin queries datasource:fetch-children.

Child rows are fetched as a single batch — no pagination. If the dataset is too large, the server should limit the response.

This method is optional. When not provided and a plugin queries for children, ServerSide emits a TBW142 diagnostic warning.

getChildRows(params: GetChildRowsParams): Promise<GetChildRowsResult<TRow>>
NameTypeDescription
paramsGetChildRowsParams