Lattice Grid Buy a licence

developer guide

Quick Filter for a JavaScript Data Grid

A quick filter narrows the whole grid from a single box, in whichever mode suits the reader: plain contains, every word in any order, fuzzy so a typo still finds the row, or a regular expression.

Developer guideSorting, filtering and find › Quick Filter for a JavaScript Data Grid

Quick filter modes

One box, four ways to match: contains (the default), words, fuzzy and regex.

grid.filters.quick('acme london', { mode: 'words' });  // every term, any column
grid.filters.quick('crc',  { mode: 'fuzzy' });        // characters in order
grid.filters.quick('^CIR-[12]', { mode: 'regex' });

grid.filters.quick('acme');       // mode persists: still 'regex' here
grid.filters.quickState();        // { text, mode }

Compiled once per query, not per row. A regular expression rebuilt for each of a hundred thousand rows is a hundred thousand compiles for one keystroke. The predicate is built in the filter stage and applied to a cached text blob per row, which is why typing stays responsive at scale.

An unfinished pattern does not blank the grid. foo( is what foo(bar) looks like halfway through typing. An invalid expression falls back to a literal search, so the list stays sensible until the pattern is valid again.

Fuzzy does not rank. Subsequence matching decides what stays; it never reorders. Sorting results by match quality would fight the sort the user chose, and a filter that quietly re-sorts is worse than one that matches too much.

Permissions still apply. The text blob is built only from columns the viewer may see. A hidden column is not searchable, or the row count becomes a way to probe the value behind it.

A column can sit out of quick search on its own. Quick search reads across every column by default; set that column's quickFilter: false to leave it out, independently of whether its own filter control is shown.