gp-grid v0.20.0
This release changes what the values (checkbox) filter mode puts into the
filter model. TextFilterCondition.selectedValues now holds the raw
cell values instead of the strings produced by the column's
valueFormatter. A formatter is a display concern, so it no longer leaks
into what a server data source receives.
Breaking changes
selectedValues is a Set of raw CellValues. Two things break:
- Backends that compared the incoming values against formatter output now receive raw values and must compare against the raw column instead.
- Filter models persisted by an earlier version — in a URL, in local storage, in a saved view — were built from labels and will no longer match anything.
Only columns with a valueFormatter are affected. Without a formatter the
label and the raw value were already the same string.
Migration guide
Match selectedValues against the raw column in your query:
// Before (v0.19.x) — selectedValues held labels like "High"
const labels = [...condition.selectedValues];
const rows = await db.query(
`SELECT * FROM tasks WHERE priority_label IN (${placeholders})`,
labels,
);
// After (v0.20.0) — selectedValues holds raw values like 2, 3
const values = [...condition.selectedValues];
const rows = await db.query(
`SELECT * FROM tasks WHERE priority IN (${placeholders})`,
values,
);If you serialize the filter model, note that JSON.stringify turns a Set
into {} — spread it into an array first. See
server-side data for a full
serializeFilter helper.
Persisted filter models need no code change, but the stored values are stale. Discard saved views built before this release, or rewrite the stored labels to their raw counterparts on read.
Related: formatters that collapse values
Because the popup groups checkboxes by label, several raw values can share
one entry, and ticking it selects every raw value behind that label — but
only the raw values the grid has discovered while scanning. On
high-cardinality columns, pre-supply the full raw domain with the column's
distinctValues option so nothing is missed:
{
field: "priority",
cellDataType: "number",
valueFormatter: (value) => ((value as number) > 1 ? "High" : "Low"),
distinctValues: [0, 1, 2, 3], // raw values, not labels
}For the complete list of changes, see the GitHub release.