Filtering
Text, number, date and set filters: not contains, one of, wildcards, regex, Korean initials, relative dates like this month, calendars, a filter row and a quick search.
Live demoFiltering
Text, number, date and set filters plus a quick search box.
Code for this demo
import { createGrid } from '@freegridjs/core';
import { demoColumns, makeRows } from '../data';
import { button, search, separator, text, tr, type DemoContext } from '../ui';
export default function mount(ctx: DemoContext) {
const { lang } = ctx;
const grid = createGrid(ctx.host, { columns: demoColumns(lang), data: makeRows(20_000), locale: lang, filterRow: true });
const count = text(ctx, '');
const update = () => (count.textContent = tr(lang, {
en: `${grid.getDisplayedRowCount().toLocaleString()} of 20,000 rows`,
ko: `20,000행 중 ${grid.getDisplayedRowCount().toLocaleString()}행`,
}));
grid.on('filterChange', e => {
ctx.log(`filterChange → ${JSON.stringify(e.filters)}`);
update();
});
search(ctx, tr(lang, { en: 'Quick search, e.g. kim -japan', ko: '빠른 검색 예: kim -japan' }), q => {
grid.setQuickFilter(q);
update();
});
separator(ctx);
button(ctx, tr(lang, { en: 'Q1 ≥ 80,000', ko: '1분기 ≥ 80,000' }), () => grid.setFilter('q1', { type: 'number', op: 'gte', value: 80000 }));
button(ctx, tr(lang, { en: 'Joined in 2024', ko: '2024년 가입' }), () =>
grid.setFilter('joined', { type: 'date', op: 'between', value: '2024-01-01', valueTo: '2024-12-31' }));
button(ctx, tr(lang, { en: 'Japan or Korea', ko: '일본 또는 한국' }), () =>
grid.setFilter('country', { type: 'set', values: ['Japan', 'South Korea'] }));
button(ctx, tr(lang, { en: 'Joined in the last 2 years', ko: '최근 2년 가입' }), () =>
grid.setFilter('joined', { type: 'date', op: 'lastDays', days: 730 }));
button(ctx, tr(lang, { en: 'Name not containing "an"', ko: '이름에 "an" 없음' }), () =>
grid.setFilter('name', { type: 'text', op: 'notContains', value: 'an' }));
button(ctx, tr(lang, { en: 'Email *[email protected]', ko: '이메일 *[email protected]' }), () =>
grid.setFilter('email', { type: 'text', op: 'like', value: '*[email protected]' }));
button(ctx, tr(lang, { en: 'Clear filters', ko: '필터 모두 해제' }), () => {
for (const id of Object.keys(grid.getFilterModel())) grid.setFilter(id, null);
});
update();
return grid;
}Each column's ⋮ menu holds a filter that matches its type: text (contains, does not contain, equals, starts/ends with, one of, wildcards, regular expression, blank…), number (=, ≠, <, ≤, >, ≥, between, blank), date (equals, before, after, between, and relative dates such as this month or the last 7 days) and set (a searchable checklist of the column's values). Text matching ignores case. A filled filter icon marks filtered columns.
grid.setFilter('name', { type: 'text', op: 'contains', value: 'kim' });
grid.setFilter('total', { type: 'number', op: 'between', value: 1000, valueTo: 5000 });
grid.setFilter('joined', { type: 'date', op: 'after', value: '2025-01-01' });
grid.setFilter('country', { type: 'set', values: ['Japan', 'South Korea'] });
grid.setFilter('name', null); // clear one
grid.setQuickFilter('kim seoul'); // every word must match some visible column
grid.on('filterChange', e => console.log(e.filters));The column menu takes up to two conditions joined with and / or, such as "at least 10 and at most 100". In code that is a combined model. Every change fires filterChange; beforeFilter comes first and can cancel it, for example to filter on your server instead. For conditions that span several columns, see Advanced filter.
// two conditions on one column, joined with and / or
grid.setFilter('qty', { type: 'combined', operator: 'and',
conditions: [{ type: 'number', op: 'gte', value: 10 }, { type: 'number', op: 'lte', value: 100 }] });
grid.getFilterModel(); // { qty: { type: 'combined', … } }
grid.on('beforeFilter', e => { if (e.colId === 'secret') e.cancel(); });More ways to search
Besides the column menu, rows can be found with text operators, relative dates, typed conditions in the filter row, editor-aware lists, Korean initials and a quick search box. Each has its own page:
- Text filter operators
- Date filters and relative dates
- Filter row syntax
- Filters on editor columns
- Korean initial consonant search
- Quick search
Filter row
filterRow: true puts a box under every header that filters as you type (applied after 0.2 s; Enter applies at once, Escape clears). Type what fits the column, as below. Text the grid cannot read turns the box red and leaves the filter as it was.
| Column | Type | Means |
|---|---|---|
| Text | kim · ㄱㅎ | Values containing "kim" (any case); Korean initials find syllables |
| Text, more | =Seoul · !test · seoul | busan · kim* · /^A\d+$/ | Exactly, does not contain, either, wildcards (* ?), regular expression |
| Number | 15 · >10 · >=10 · <5 · <=5 · <>3 | Equal, greater, at least, less, at most, not equal (1,000 and currency signs are read too) |
| Number range | 10~20 · 10..20 | From 10 to 20 |
| Date | 2026-03-05 · >2026-01-01 · <2026-12-31 | That day, after, before (dots or slashes work too: 2026.3.5) |
| Date range | 2026-01-01~2026-03-31 | Between the two days, both included |
| Date, calendar | The calendar button in the box | Relative choices (today, this week, this month, last 7 days…) or two clicks for a range; the box shows the choice, such as This month |
| Set and true/false | A drop-down | Columns with filter: 'set', boolean columns and option editors (select, radio, multi-select, switch) pick one value, shown by label |
The filter row, the column menu and setFilter() share one filter, so a change in one shows in the others. A list filter that lets several values through (picked in the column menu) shows as (2 selected) in the filter row's list. Leave a column out with filter: false. What you are typing stays put when live updates change the rows.
const grid = createGrid(el, {
columns: [
{ field: 'name', header: 'Name' }, // text: contains
{ field: 'qty', header: 'Qty', type: 'number' }, // >10, <=5, 10~20
{ field: 'joined', header: 'Joined', type: 'date' }, // >2026-01-01, 2026-01-01~2026-03-31
{ field: 'status', header: 'Status', filter: 'set' }, // a list of the column's values
{ field: 'memo', header: 'Memo', filter: false }, // no box
],
data,
filterRow: true,
});
// the boxes and the column menu share one filter: setting one updates the other
grid.setFilter('qty', { type: 'number', op: 'between', value: 10, valueTo: 20 }); // the box shows 10~20Questions about this page
What filters does FreeGrid have?
Text, number, date and set (list of values) filters in the column menu with up to two conditions per column, a filter row under the header and a quick search box.