Skip to content

Data Updates

Enterprise

Grids rarely sit on static data — rows stream in, get edited, or are replaced by a refresh. This page is about what a List Filter does when the data underneath it changes. Three things move:

  1. The value list follows the data. setFilter() reads the column’s distinct values lazily, so every time the funnel opens it reflects the current data — new values appear, gone values disappear, and showCount totals update.
  2. An active filter re-applies automatically. Replace the data with grid.setData(...) and the applied in filter re-runs against the new rows — you don’t lose the filter, and it stays correct.
  3. The selection is reconciled by policy. What happens to the checked values when new data arrives is up to you — keep them, clear them, or grow them to cover new values — via newRowsAction.

newRowsAction is an option on setFilter():

Value When the data changes…
keep (default) The selection is preserved as-is. New values that appear are not ticked, so their rows stay hidden until the reader adds them.
clear The filter is dropped — every row shows again. Use it when a refresh invalidates the current selection.
select The selection grows to include any brand-new values, so rows carrying them stay visible.

keep needs nothing extra — the re-apply is built into the grid. clear and select are driven by a small manager you attach once:

import { setFilter, attachSetFilterUpdates } from '@zengrid/enterprise';
const columns = [
setFilter({ field: 'region', header: 'Region', newRowsAction: 'select' }),
// …
];
const grid = new Zengrid(el, { columns });
attachSetFilterUpdates(grid, columns); // reads each column's newRowsAction
grid.setData(nextRows); // a new region auto-joins the active selection

attachSetFilterUpdates(grid, columns) wraps setData: after each data change it reads every setFilter column’s newRowsAction and reconciles that column’s selection. Columns left on the default keep are simply not touched.

When a column supplies its own values (an array or a values getter), the option list is decoupled from the data — data changes don’t add or remove options, and select won’t auto-add data-only values (the supplied list owns what’s offered). When the list is derived from the column, it tracks the data and select can grow it.

Each variant seeds a small dataset and gives you buttons that stand in for your app pushing new data. Apply a filter, then change the data, and watch how the selection responds — reopen the funnel to see the value list track the data too.

Filter Region → APAC + EU-West, then Change the data. The filter re-applies to the new rows on its own: the LATAM→EU-West row joins the view, while the two new MEA rows stay hidden (MEA isn’t ticked — the default "keep"). Reopen the funnel — MEA is now in the list with its count.

Option What it does
newRowsAction Selection policy on data change: keep (default), clear, or select. Anything but keep needs attachSetFilterUpdates.
attachSetFilterUpdates(grid, columns) Wire the manager: wraps setData and reconciles each setFilter column per its newRowsAction. Returns a handle with detach().
  • Value List — shape the value list itself (supply, sort, format), including the supplied-vs-derived distinction that governs select.
  • List Filter — the checkbox filter these updates apply to, and how a selection maps to an in condition.
  • Applying Filters — the grid.filter API the buttons above drive.