날짜·시간 범위로 거르기Filter by a date or time range
날짜, 시간, 날짜+시간 컬럼의 필터 행에 하루, 이상·이하, 범위(..)를 글자로 쓰거나 버튼으로 걸어요. 어떤 방식이든 같은 필터 모델이 만들어져요.In the filter row of date, time and datetime columns, write a whole day, at-least or at-most, or a range (..) as text, or apply one with a button. Every way builds the same filter model.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="day">그날 하루</button>
<button type="button" id="from">11일 이후</button>
<button type="button" id="between">범위</button>
<button type="button" id="morning">오전 시간대</button>
<button type="button" id="clear">필터 지우기</button>
</div>
<div id="grid" style="height: 560px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('day').addEventListener('click', () => actions.day(api));
document.getElementById('from').addEventListener('click', () => actions.from(api));
document.getElementById('between').addEventListener('click', () => actions.between(api));
document.getElementById('morning').addEventListener('click', () => actions.morning(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요. 샘플 데이터는 한국어 그대로예요.
const pageLang = () => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// 페이지 언어가 바뀌면 그리드 locale도 따라 바꿔요. 해제 함수를 돌려줘요.
function followPageLanguage(api) {
const watcher = new MutationObserver(() => api.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => watcher.disconnect();
}
// 날짜는 'YYYY-MM-DD', 시간은 'HH:mm', 날짜+시간은 'YYYY-MM-DD HH:mm' 문자열이에요(시간대 없음).
export const options = {
columns: [
{ id: 'event', title: '일정', width: 130 },
{ id: 'at', title: '일시', kind: 'datetime', width: 170 },
{ id: 'start', title: '시작 시각', kind: 'time', width: 120 },
{ id: 'due', title: '마감일', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: '고객 미팅', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: '코드 리뷰', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: '배포', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: '회고', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: pageLang(),
};
// 버튼이 거는 필터. 필터 행에 직접 쓰는 것(>=2026-11-11, 09:00..12:00)과 같은 모델이에요.
const PRESETS = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api, log) {
const off = api.on('filterChanged', ({ filterModel }) => log(filterModel === null
? { ko: '필터 없음', en: 'No filter' }
: {
ko: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()}줄`,
en: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
}));
const stop = followPageLanguage(api);
return () => {
off();
stop();
};
}
export const actions = {
day: (api) => api.setFilterModel(PRESETS.day ?? null),
from: (api) => api.setFilterModel(PRESETS.from ?? null),
between: (api) => api.setFilterModel(PRESETS.between ?? null),
morning: (api) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api) => api.setFilterModel(null),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>날짜·시간 범위로 거르기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="day">그날 하루</button>
<button type="button" id="from">11일 이후</button>
<button type="button" id="between">범위</button>
<button type="button" id="morning">오전 시간대</button>
<button type="button" id="clear">필터 지우기</button>
</div>
<div id="grid" style="height: 560px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요. 샘플 데이터는 한국어 그대로예요.
const pageLang = () => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// 페이지 언어가 바뀌면 그리드 locale도 따라 바꿔요. 해제 함수를 돌려줘요.
function followPageLanguage(api) {
const watcher = new MutationObserver(() => api.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => watcher.disconnect();
}
// 날짜는 'YYYY-MM-DD', 시간은 'HH:mm', 날짜+시간은 'YYYY-MM-DD HH:mm' 문자열이에요(시간대 없음).
const options = {
columns: [
{ id: 'event', title: '일정', width: 130 },
{ id: 'at', title: '일시', kind: 'datetime', width: 170 },
{ id: 'start', title: '시작 시각', kind: 'time', width: 120 },
{ id: 'due', title: '마감일', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: '고객 미팅', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: '코드 리뷰', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: '배포', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: '회고', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: pageLang(),
};
// 버튼이 거는 필터. 필터 행에 직접 쓰는 것(>=2026-11-11, 09:00..12:00)과 같은 모델이에요.
const PRESETS = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
function setup(api, log) {
const off = api.on('filterChanged', ({ filterModel }) => log(filterModel === null
? { ko: '필터 없음', en: 'No filter' }
: {
ko: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()}줄`,
en: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
}));
const stop = followPageLanguage(api);
return () => {
off();
stop();
};
}
const actions = {
day: (api) => api.setFilterModel(PRESETS.day ?? null),
from: (api) => api.setFilterModel(PRESETS.from ?? null),
between: (api) => api.setFilterModel(PRESETS.between ?? null),
morning: (api) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api) => api.setFilterModel(null),
};
options.ariaLabel = "날짜·시간 범위로 거르기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('day').addEventListener('click', () => actions.day(api));
document.getElementById('from').addEventListener('click', () => actions.from(api));
document.getElementById('between').addEventListener('click', () => actions.between(api));
document.getElementById('morning').addEventListener('click', () => actions.morning(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.day(api)}
>그날 하루</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.from(api)}
>11일 이후</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.between(api)}
>범위</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.morning(api)}
>오전 시간대</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>필터 지우기</button>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { FilterModel, GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요. 샘플 데이터는 한국어 그대로예요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// 페이지 언어가 바뀌면 그리드 locale도 따라 바꿔요. 해제 함수를 돌려줘요.
function followPageLanguage(api: GridApi<Row>): () => void {
const watcher = new MutationObserver(() => api.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => watcher.disconnect();
}
// 날짜는 'YYYY-MM-DD', 시간은 'HH:mm', 날짜+시간은 'YYYY-MM-DD HH:mm' 문자열이에요(시간대 없음).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: '일정', width: 130 },
{ id: 'at', title: '일시', kind: 'datetime', width: 170 },
{ id: 'start', title: '시작 시각', kind: 'time', width: 120 },
{ id: 'due', title: '마감일', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: '고객 미팅', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: '코드 리뷰', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: '배포', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: '회고', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: pageLang(),
};
// 버튼이 거는 필터. 필터 행에 직접 쓰는 것(>=2026-11-11, 09:00..12:00)과 같은 모델이에요.
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? { ko: '필터 없음', en: 'No filter' }
: {
ko: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()}줄`,
en: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
},
),
);
const stop = followPageLanguage(api);
return () => {
off();
stop();
};
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.day(api)">그날 하루</button>
<button type="button" :disabled="!api" @click="api && actions.from(api)">11일 이후</button>
<button type="button" :disabled="!api" @click="api && actions.between(api)">범위</button>
<button type="button" :disabled="!api" @click="api && actions.morning(api)">오전 시간대</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">필터 지우기</button>
</div>
<Grid style="height: 560px" :options="options" @ready="onReady" />
</template>import type { FilterModel, GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요. 샘플 데이터는 한국어 그대로예요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// 페이지 언어가 바뀌면 그리드 locale도 따라 바꿔요. 해제 함수를 돌려줘요.
function followPageLanguage(api: GridApi<Row>): () => void {
const watcher = new MutationObserver(() => api.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => watcher.disconnect();
}
// 날짜는 'YYYY-MM-DD', 시간은 'HH:mm', 날짜+시간은 'YYYY-MM-DD HH:mm' 문자열이에요(시간대 없음).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: '일정', width: 130 },
{ id: 'at', title: '일시', kind: 'datetime', width: 170 },
{ id: 'start', title: '시작 시각', kind: 'time', width: 120 },
{ id: 'due', title: '마감일', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: '고객 미팅', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: '코드 리뷰', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: '배포', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: '회고', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: pageLang(),
};
// 버튼이 거는 필터. 필터 행에 직접 쓰는 것(>=2026-11-11, 09:00..12:00)과 같은 모델이에요.
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? { ko: '필터 없음', en: 'No filter' }
: {
ko: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()}줄`,
en: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
},
),
);
const stop = followPageLanguage(api);
return () => {
off();
stop();
};
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.day(api)"
>그날 하루</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.from(api)"
>11일 이후</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.between(api)"
>범위</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.morning(api)"
>오전 시간대</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>필터 지우기</button>
</div>
<mx-grid style="height: 560px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { FilterModel, GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요. 샘플 데이터는 한국어 그대로예요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// 페이지 언어가 바뀌면 그리드 locale도 따라 바꿔요. 해제 함수를 돌려줘요.
function followPageLanguage(api: GridApi<Row>): () => void {
const watcher = new MutationObserver(() => api.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => watcher.disconnect();
}
// 날짜는 'YYYY-MM-DD', 시간은 'HH:mm', 날짜+시간은 'YYYY-MM-DD HH:mm' 문자열이에요(시간대 없음).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: '일정', width: 130 },
{ id: 'at', title: '일시', kind: 'datetime', width: 170 },
{ id: 'start', title: '시작 시각', kind: 'time', width: 120 },
{ id: 'due', title: '마감일', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: '고객 미팅', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: '코드 리뷰', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: '배포', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: '회고', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: pageLang(),
};
// 버튼이 거는 필터. 필터 행에 직접 쓰는 것(>=2026-11-11, 09:00..12:00)과 같은 모델이에요.
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? { ko: '필터 없음', en: 'No filter' }
: {
ko: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()}줄`,
en: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
},
),
);
const stop = followPageLanguage(api);
return () => {
off();
stop();
};
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<button type="button" id="day">One whole day</button>
<button type="button" id="from">From Nov 11</button>
<button type="button" id="between">A range</button>
<button type="button" id="morning">Morning hours</button>
<button type="button" id="clear">Clear filter</button>
</div>
<div id="grid" style="height: 560px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('day').addEventListener('click', () => actions.day(api));
document.getElementById('from').addEventListener('click', () => actions.from(api));
document.getElementById('between').addEventListener('click', () => actions.between(api));
document.getElementById('morning').addEventListener('click', () => actions.morning(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));// Dates are 'YYYY-MM-DD' strings, times are 'HH:mm', and date + time is 'YYYY-MM-DD HH:mm' (no time zone).
export const options = {
columns: [
{ id: 'event', title: 'Event', width: 150 },
{ id: 'at', title: 'At', kind: 'datetime', width: 170 },
{ id: 'start', title: 'Start', kind: 'time', width: 120 },
{ id: 'due', title: 'Due date', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: 'Weekly sync', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: 'Client meeting', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: 'Code review', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: 'Release', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: 'Retrospective', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: 'en',
};
// The filters the buttons apply. The same models as typing into the filter row (>=2026-11-11, 09:00..12:00).
const PRESETS = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api, log) {
const off = api.on('filterChanged', ({ filterModel }) => log(filterModel === null
? 'No filter'
: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`));
return () => off();
}
export const actions = {
day: (api) => api.setFilterModel(PRESETS.day ?? null),
from: (api) => api.setFilterModel(PRESETS.from ?? null),
between: (api) => api.setFilterModel(PRESETS.between ?? null),
morning: (api) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api) => api.setFilterModel(null),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Filter by a date or time range</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="day">One whole day</button>
<button type="button" id="from">From Nov 11</button>
<button type="button" id="between">A range</button>
<button type="button" id="morning">Morning hours</button>
<button type="button" id="clear">Clear filter</button>
</div>
<div id="grid" style="height: 560px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// Dates are 'YYYY-MM-DD' strings, times are 'HH:mm', and date + time is 'YYYY-MM-DD HH:mm' (no time zone).
const options = {
columns: [
{ id: 'event', title: 'Event', width: 150 },
{ id: 'at', title: 'At', kind: 'datetime', width: 170 },
{ id: 'start', title: 'Start', kind: 'time', width: 120 },
{ id: 'due', title: 'Due date', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: 'Weekly sync', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: 'Client meeting', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: 'Code review', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: 'Release', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: 'Retrospective', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: 'en',
};
// The filters the buttons apply. The same models as typing into the filter row (>=2026-11-11, 09:00..12:00).
const PRESETS = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
function setup(api, log) {
const off = api.on('filterChanged', ({ filterModel }) => log(filterModel === null
? 'No filter'
: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`));
return () => off();
}
const actions = {
day: (api) => api.setFilterModel(PRESETS.day ?? null),
from: (api) => api.setFilterModel(PRESETS.from ?? null),
between: (api) => api.setFilterModel(PRESETS.between ?? null),
morning: (api) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api) => api.setFilterModel(null),
};
options.ariaLabel = "Filter by a date or time range";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('day').addEventListener('click', () => actions.day(api));
document.getElementById('from').addEventListener('click', () => actions.from(api));
document.getElementById('between').addEventListener('click', () => actions.between(api));
document.getElementById('morning').addEventListener('click', () => actions.morning(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.day(api)}
>One whole day</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.from(api)}
>From Nov 11</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.between(api)}
>A range</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.morning(api)}
>Morning hours</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>Clear filter</button>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { FilterModel, GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// Dates are 'YYYY-MM-DD' strings, times are 'HH:mm', and date + time is 'YYYY-MM-DD HH:mm' (no time zone).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: 'Event', width: 150 },
{ id: 'at', title: 'At', kind: 'datetime', width: 170 },
{ id: 'start', title: 'Start', kind: 'time', width: 120 },
{ id: 'due', title: 'Due date', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: 'Weekly sync', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: 'Client meeting', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: 'Code review', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: 'Release', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: 'Retrospective', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: 'en',
};
// The filters the buttons apply. The same models as typing into the filter row (>=2026-11-11, 09:00..12:00).
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? 'No filter'
: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
),
);
return () => off();
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.day(api)">One whole day</button>
<button type="button" :disabled="!api" @click="api && actions.from(api)">From Nov 11</button>
<button type="button" :disabled="!api" @click="api && actions.between(api)">A range</button>
<button type="button" :disabled="!api" @click="api && actions.morning(api)">Morning hours</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">Clear filter</button>
</div>
<Grid style="height: 560px" :options="options" @ready="onReady" />
</template>import type { FilterModel, GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// Dates are 'YYYY-MM-DD' strings, times are 'HH:mm', and date + time is 'YYYY-MM-DD HH:mm' (no time zone).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: 'Event', width: 150 },
{ id: 'at', title: 'At', kind: 'datetime', width: 170 },
{ id: 'start', title: 'Start', kind: 'time', width: 120 },
{ id: 'due', title: 'Due date', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: 'Weekly sync', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: 'Client meeting', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: 'Code review', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: 'Release', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: 'Retrospective', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: 'en',
};
// The filters the buttons apply. The same models as typing into the filter row (>=2026-11-11, 09:00..12:00).
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? 'No filter'
: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
),
);
return () => off();
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.day(api)"
>One whole day</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.from(api)"
>From Nov 11</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.between(api)"
>A range</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.morning(api)"
>Morning hours</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>Clear filter</button>
</div>
<mx-grid style="height: 560px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { FilterModel, GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
event: string;
at: string;
start: string;
due: string;
}
// Dates are 'YYYY-MM-DD' strings, times are 'HH:mm', and date + time is 'YYYY-MM-DD HH:mm' (no time zone).
export const options: GridOptions<Row> = {
columns: [
{ id: 'event', title: 'Event', width: 150 },
{ id: 'at', title: 'At', kind: 'datetime', width: 170 },
{ id: 'start', title: 'Start', kind: 'time', width: 120 },
{ id: 'due', title: 'Due date', kind: 'date', width: 130 },
],
rows: [
{ id: 1, event: 'Weekly sync', at: '2026-11-10 10:00', start: '10:00', due: '2026-11-10' },
{ id: 2, event: 'Client meeting', at: '2026-11-10 14:30', start: '14:30', due: '2026-11-12' },
{ id: 3, event: 'Code review', at: '2026-11-11 16:05', start: '16:05', due: '2026-11-13' },
{ id: 4, event: 'Release', at: '2026-11-12 09:00', start: '09:00', due: '2026-11-20' },
{ id: 5, event: 'Retrospective', at: '2026-11-13 11:15', start: '11:15', due: '2026-11-27' },
],
rowKey: 'id',
filterRow: true,
filterMenu: true,
locale: 'en',
};
// The filters the buttons apply. The same models as typing into the filter row (>=2026-11-11, 09:00..12:00).
const PRESETS: Record<string, FilterModel> = {
day: { match: 'all', items: [{ columnId: 'at', operator: 'equals', value: '2026-11-10' }] },
from: { match: 'all', items: [{ columnId: 'at', operator: 'gte', value: '2026-11-11 00:00' }] },
between: {
match: 'all',
items: [
{ columnId: 'at', operator: 'between', value: ['2026-11-10 10:00', '2026-11-11 16:05'] },
],
},
morning: {
match: 'all',
items: [{ columnId: 'start', operator: 'between', value: ['09:00', '12:00'] }],
},
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
const off = api.on('filterChanged', ({ filterModel }) =>
log(
filterModel === null
? 'No filter'
: `${filterModel.items.map((i) => `${i.columnId} ${i.operator} ${JSON.stringify(i.value ?? '')}`).join(' · ')} → ${api.getVisibleRowCount()} rows`,
),
);
return () => off();
}
export const actions = {
day: (api: GridApi<Row>) => api.setFilterModel(PRESETS.day ?? null),
from: (api: GridApi<Row>) => api.setFilterModel(PRESETS.from ?? null),
between: (api: GridApi<Row>) => api.setFilterModel(PRESETS.between ?? null),
morning: (api: GridApi<Row>) => api.setFilterModel(PRESETS.morning ?? null),
clear: (api: GridApi<Row>) => api.setFilterModel(null),
};