@jsvision/datagrid / computeDistinct
Function: computeDistinct()
computeDistinct<
T>(rows,col,i18n?):string[]
Defined in: datagrid/src/filter.ts:215
The sorted distinct formatted labels for a column over a row snapshot — the grid-owned client distinct enumeration. Dedups format(value) across the rows (a nil value contributes one '' entry) and sorts by the shared case-insensitive collator. Never truncates; the caller wraps the result as { values, truncated: false }.
Type Parameters
T
T
Parameters
rows
readonly T[]
The row snapshot to scan.
col
GridColumn<T>
The column whose distinct labels to enumerate.
i18n?
I18n
Optional explicit service for locale-aware ordering.
Returns
string[]
The distinct labels, sorted case-insensitively.
Example
ts
import { column, computeDistinct } from '@jsvision/datagrid';
interface Sale { region: string; }
const rows: Sale[] = [{ region: 'west' }, { region: 'east' }, { region: 'north' }, { region: 'east' }];
const region = column({ id: 'region', title: 'Region', value: (r: Sale) => r.region });
const labels = computeDistinct(rows, region); // e.g. ['east', 'north', 'west']