주 컬럼 필터와 내보내기Filter and export a week column
주 컬럼(kind: 'week')은 필터 칸에서 달력으로 고르거나 >=2026-W10 처럼 쓸 수 있고, 내보내기에는 YYYY-Www 글자로 나가요(xlsx도 글자 셀).A week column (kind: 'week') can be filtered by picking from the calendar or typing >=2026-W10, and exports as YYYY-Www text (also a text cell in xlsx).
코드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)
이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="fromW10">2026-W10 이후</button>
<button type="button" id="firstHalf">상반기</button>
<button type="button" id="clear">필터 지우기</button>
<button type="button" id="csv">CSV 보기</button>
</div>
<div id="grid" style="height: 300px"></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('fromW10').addEventListener('click', () => actions.fromW10(api));
document.getElementById('firstHalf').addEventListener('click', () => actions.firstHalf(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
document.getElementById('csv').addEventListener('click', () => actions.csv(api));import { exportCsv } from '@maxgrid/export';
const en = document.documentElement.dataset.lang === 'en';
const rows = [
{ id: 1, item: en ? 'Design' : '설계', week: '2026-W02', hours: 12 },
{ id: 2, item: en ? 'Develop' : '개발', week: '2026-W10', hours: 40 },
{ id: 3, item: en ? 'Test' : '시험', week: '2026-W26', hours: 24 },
{ id: 4, item: en ? 'Release' : '배포', week: '2026-W47', hours: 8 },
{ id: 5, item: en ? 'Undecided' : '미정', week: null, hours: 0 },
];
// 주 컬럼의 필터 칸은 달력 단추로 주를 고르거나 >=2026-W10 · 2026-W01..2026-W26 처럼 써도 돼요.
export const options = {
columns: [
{ id: 'item', title: en ? 'Item' : '항목', width: 130 },
{
id: 'week',
title: en ? 'Work week' : '작업 주',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: en ? 'Hours' : '시간', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: en ? 'Week filter and export' : '주 필터와 내보내기',
};
let say = () => { };
export function setup(_api, log) {
say = log;
log({
ko: '작업 주 필터 칸의 달력 단추를 눌러 주를 고르거나 >=2026-W10 처럼 써 보세요.',
en: 'Use the calendar button in the week filter cell, or type something like >=2026-W10.',
});
}
export const actions = {
fromW10: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say({ ko: '2026-W10 이후만 남겼어요.', en: 'Kept 2026-W10 and later.' });
},
firstHalf: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say({ ko: '2026-W01~2026-W26만 남겼어요.', en: 'Kept 2026-W01 to 2026-W26.' });
},
clear: (api) => api.setFilterModel(null),
csv: (api) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say({
ko: `CSV(보이는 행): ${text.trim().split('\n').slice(1).join(' | ')}`,
en: `CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`,
});
},
}; 이 HTML은 추가 번들(위 script 태그)도 함께 불러오고 전역 변수로 써요. 별도 설치는 필요 없어요.
<!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="fromW10">2026-W10 이후</button>
<button type="button" id="firstHalf">상반기</button>
<button type="button" id="clear">필터 지우기</button>
<button type="button" id="csv">CSV 보기</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.export.min.js"></script>
<script>
const { exportCsv } = MaxGridExport;
const en = document.documentElement.dataset.lang === 'en';
const rows = [
{ id: 1, item: en ? 'Design' : '설계', week: '2026-W02', hours: 12 },
{ id: 2, item: en ? 'Develop' : '개발', week: '2026-W10', hours: 40 },
{ id: 3, item: en ? 'Test' : '시험', week: '2026-W26', hours: 24 },
{ id: 4, item: en ? 'Release' : '배포', week: '2026-W47', hours: 8 },
{ id: 5, item: en ? 'Undecided' : '미정', week: null, hours: 0 },
];
// 주 컬럼의 필터 칸은 달력 단추로 주를 고르거나 >=2026-W10 · 2026-W01..2026-W26 처럼 써도 돼요.
const options = {
columns: [
{ id: 'item', title: en ? 'Item' : '항목', width: 130 },
{
id: 'week',
title: en ? 'Work week' : '작업 주',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: en ? 'Hours' : '시간', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: en ? 'Week filter and export' : '주 필터와 내보내기',
};
let say = () => { };
function setup(_api, log) {
say = log;
log({
ko: '작업 주 필터 칸의 달력 단추를 눌러 주를 고르거나 >=2026-W10 처럼 써 보세요.',
en: 'Use the calendar button in the week filter cell, or type something like >=2026-W10.',
});
}
const actions = {
fromW10: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say({ ko: '2026-W10 이후만 남겼어요.', en: 'Kept 2026-W10 and later.' });
},
firstHalf: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say({ ko: '2026-W01~2026-W26만 남겼어요.', en: 'Kept 2026-W01 to 2026-W26.' });
},
clear: (api) => api.setFilterModel(null),
csv: (api) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say({
ko: `CSV(보이는 행): ${text.trim().split('\n').slice(1).join(' | ')}`,
en: `CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`,
});
},
};
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('fromW10').addEventListener('click', () => actions.fromW10(api));
document.getElementById('firstHalf').addEventListener('click', () => actions.firstHalf(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
document.getElementById('csv').addEventListener('click', () => actions.csv(api));
</script>
</body>
</html> 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/react @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 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.fromW10(api)}
>2026-W10 이후</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.firstHalf(api)}
>상반기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>필터 지우기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.csv(api)}
>CSV 보기</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/react';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: en ? 'Design' : '설계', week: '2026-W02', hours: 12 },
{ id: 2, item: en ? 'Develop' : '개발', week: '2026-W10', hours: 40 },
{ id: 3, item: en ? 'Test' : '시험', week: '2026-W26', hours: 24 },
{ id: 4, item: en ? 'Release' : '배포', week: '2026-W47', hours: 8 },
{ id: 5, item: en ? 'Undecided' : '미정', week: null, hours: 0 },
];
// 주 컬럼의 필터 칸은 달력 단추로 주를 고르거나 >=2026-W10 · 2026-W01..2026-W26 처럼 써도 돼요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: en ? 'Item' : '항목', width: 130 },
{
id: 'week',
title: en ? 'Work week' : '작업 주',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: en ? 'Hours' : '시간', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: en ? 'Week filter and export' : '주 필터와 내보내기',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '작업 주 필터 칸의 달력 단추를 눌러 주를 고르거나 >=2026-W10 처럼 써 보세요.',
en: 'Use the calendar button in the week filter cell, or type something like >=2026-W10.',
});
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say({ ko: '2026-W10 이후만 남겼어요.', en: 'Kept 2026-W10 and later.' });
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say({ ko: '2026-W01~2026-W26만 남겼어요.', en: 'Kept 2026-W01 to 2026-W26.' });
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say({
ko: `CSV(보이는 행): ${text.trim().split('\n').slice(1).join(' | ')}`,
en: `CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`,
});
},
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/vue @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 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.fromW10(api)">2026-W10 이후</button>
<button
type="button"
:disabled="!api"
@click="api && actions.firstHalf(api)"
>상반기</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">필터 지우기</button>
<button type="button" :disabled="!api" @click="api && actions.csv(api)">CSV 보기</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/vue';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: en ? 'Design' : '설계', week: '2026-W02', hours: 12 },
{ id: 2, item: en ? 'Develop' : '개발', week: '2026-W10', hours: 40 },
{ id: 3, item: en ? 'Test' : '시험', week: '2026-W26', hours: 24 },
{ id: 4, item: en ? 'Release' : '배포', week: '2026-W47', hours: 8 },
{ id: 5, item: en ? 'Undecided' : '미정', week: null, hours: 0 },
];
// 주 컬럼의 필터 칸은 달력 단추로 주를 고르거나 >=2026-W10 · 2026-W01..2026-W26 처럼 써도 돼요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: en ? 'Item' : '항목', width: 130 },
{
id: 'week',
title: en ? 'Work week' : '작업 주',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: en ? 'Hours' : '시간', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: en ? 'Week filter and export' : '주 필터와 내보내기',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '작업 주 필터 칸의 달력 단추를 눌러 주를 고르거나 >=2026-W10 처럼 써 보세요.',
en: 'Use the calendar button in the week filter cell, or type something like >=2026-W10.',
});
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say({ ko: '2026-W10 이후만 남겼어요.', en: 'Kept 2026-W10 and later.' });
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say({ ko: '2026-W01~2026-W26만 남겼어요.', en: 'Kept 2026-W01 to 2026-W26.' });
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say({
ko: `CSV(보이는 행): ${text.trim().split('\n').slice(1).join(' | ')}`,
en: `CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`,
});
},
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/angular @maxgrid/export로 설치하세요.
버튼을 누르면 이 예제의 코드가 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.fromW10(api)"
>2026-W10 이후</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.firstHalf(api)"
>상반기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>필터 지우기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.csv(api)"
>CSV 보기</button>
</div>
<mx-grid style="height: 300px" [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 { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/angular';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: en ? 'Design' : '설계', week: '2026-W02', hours: 12 },
{ id: 2, item: en ? 'Develop' : '개발', week: '2026-W10', hours: 40 },
{ id: 3, item: en ? 'Test' : '시험', week: '2026-W26', hours: 24 },
{ id: 4, item: en ? 'Release' : '배포', week: '2026-W47', hours: 8 },
{ id: 5, item: en ? 'Undecided' : '미정', week: null, hours: 0 },
];
// 주 컬럼의 필터 칸은 달력 단추로 주를 고르거나 >=2026-W10 · 2026-W01..2026-W26 처럼 써도 돼요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: en ? 'Item' : '항목', width: 130 },
{
id: 'week',
title: en ? 'Work week' : '작업 주',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: en ? 'Hours' : '시간', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: en ? 'Week filter and export' : '주 필터와 내보내기',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '작업 주 필터 칸의 달력 단추를 눌러 주를 고르거나 >=2026-W10 처럼 써 보세요.',
en: 'Use the calendar button in the week filter cell, or type something like >=2026-W10.',
});
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say({ ko: '2026-W10 이후만 남겼어요.', en: 'Kept 2026-W10 and later.' });
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say({ ko: '2026-W01~2026-W26만 남겼어요.', en: 'Kept 2026-W01 to 2026-W26.' });
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say({
ko: `CSV(보이는 행): ${text.trim().split('\n').slice(1).join(' | ')}`,
en: `CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`,
});
},
}; This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/export.
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="fromW10">From 2026-W10</button>
<button type="button" id="firstHalf">First half</button>
<button type="button" id="clear">Clear filter</button>
<button type="button" id="csv">Show CSV</button>
</div>
<div id="grid" style="height: 300px"></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('fromW10').addEventListener('click', () => actions.fromW10(api));
document.getElementById('firstHalf').addEventListener('click', () => actions.firstHalf(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
document.getElementById('csv').addEventListener('click', () => actions.csv(api));import { exportCsv } from '@maxgrid/export';
const rows = [
{ id: 1, item: 'Design', week: '2026-W02', hours: 12 },
{ id: 2, item: 'Develop', week: '2026-W10', hours: 40 },
{ id: 3, item: 'Test', week: '2026-W26', hours: 24 },
{ id: 4, item: 'Release', week: '2026-W47', hours: 8 },
{ id: 5, item: 'Undecided', week: null, hours: 0 },
];
// The filter cell of the week column accepts a week picked with the calendar button, or typed text like >=2026-W10 or 2026-W01..2026-W26.
export const options = {
columns: [
{ id: 'item', title: 'Item', width: 130 },
{
id: 'week',
title: 'Work week',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: 'Hours', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: 'Week filter and export',
};
let say = () => { };
export function setup(_api, log) {
say = log;
log('Use the calendar button in the week filter cell, or type something like >=2026-W10.');
}
export const actions = {
fromW10: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say('Kept 2026-W10 and later.');
},
firstHalf: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say('Kept 2026-W01 to 2026-W26.');
},
clear: (api) => api.setFilterModel(null),
csv: (api) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say(`CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`);
},
};This HTML also loads an extra bundle (the extra script tag above) and uses it as a global. No install is needed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Filter and export a week column</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="fromW10">From 2026-W10</button>
<button type="button" id="firstHalf">First half</button>
<button type="button" id="clear">Clear filter</button>
<button type="button" id="csv">Show CSV</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.export.min.js"></script>
<script>
const { exportCsv } = MaxGridExport;
const rows = [
{ id: 1, item: 'Design', week: '2026-W02', hours: 12 },
{ id: 2, item: 'Develop', week: '2026-W10', hours: 40 },
{ id: 3, item: 'Test', week: '2026-W26', hours: 24 },
{ id: 4, item: 'Release', week: '2026-W47', hours: 8 },
{ id: 5, item: 'Undecided', week: null, hours: 0 },
];
// The filter cell of the week column accepts a week picked with the calendar button, or typed text like >=2026-W10 or 2026-W01..2026-W26.
const options = {
columns: [
{ id: 'item', title: 'Item', width: 130 },
{
id: 'week',
title: 'Work week',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: 'Hours', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: 'Week filter and export',
};
let say = () => { };
function setup(_api, log) {
say = log;
log('Use the calendar button in the week filter cell, or type something like >=2026-W10.');
}
const actions = {
fromW10: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say('Kept 2026-W10 and later.');
},
firstHalf: (api) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say('Kept 2026-W01 to 2026-W26.');
},
clear: (api) => api.setFilterModel(null),
csv: (api) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say(`CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`);
},
};
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('fromW10').addEventListener('click', () => actions.fromW10(api));
document.getElementById('firstHalf').addEventListener('click', () => actions.firstHalf(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));
document.getElementById('csv').addEventListener('click', () => actions.csv(api));
</script>
</body>
</html> This example needs an extra package. To run it locally, install with npm i @maxgrid/react @maxgrid/export.
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.fromW10(api)}
>From 2026-W10</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.firstHalf(api)}
>First half</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>Clear filter</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.csv(api)}
>Show CSV</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: 'Design', week: '2026-W02', hours: 12 },
{ id: 2, item: 'Develop', week: '2026-W10', hours: 40 },
{ id: 3, item: 'Test', week: '2026-W26', hours: 24 },
{ id: 4, item: 'Release', week: '2026-W47', hours: 8 },
{ id: 5, item: 'Undecided', week: null, hours: 0 },
];
// The filter cell of the week column accepts a week picked with the calendar button, or typed text like >=2026-W10 or 2026-W01..2026-W26.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 130 },
{
id: 'week',
title: 'Work week',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: 'Hours', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: 'Week filter and export',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Use the calendar button in the week filter cell, or type something like >=2026-W10.');
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say('Kept 2026-W10 and later.');
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say('Kept 2026-W01 to 2026-W26.');
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say(`CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`);
},
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/vue @maxgrid/export.
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.fromW10(api)">From 2026-W10</button>
<button
type="button"
:disabled="!api"
@click="api && actions.firstHalf(api)"
>First half</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">Clear filter</button>
<button type="button" :disabled="!api" @click="api && actions.csv(api)">Show CSV</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: 'Design', week: '2026-W02', hours: 12 },
{ id: 2, item: 'Develop', week: '2026-W10', hours: 40 },
{ id: 3, item: 'Test', week: '2026-W26', hours: 24 },
{ id: 4, item: 'Release', week: '2026-W47', hours: 8 },
{ id: 5, item: 'Undecided', week: null, hours: 0 },
];
// The filter cell of the week column accepts a week picked with the calendar button, or typed text like >=2026-W10 or 2026-W01..2026-W26.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 130 },
{
id: 'week',
title: 'Work week',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: 'Hours', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: 'Week filter and export',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Use the calendar button in the week filter cell, or type something like >=2026-W10.');
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say('Kept 2026-W10 and later.');
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say('Kept 2026-W01 to 2026-W26.');
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say(`CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`);
},
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/angular @maxgrid/export.
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.fromW10(api)"
>From 2026-W10</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.firstHalf(api)"
>First half</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>Clear filter</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.csv(api)"
>Show CSV</button>
</div>
<mx-grid style="height: 300px" [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 { exportCsv } from '@maxgrid/export';
import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
item: string;
week: string | null;
hours: number;
}
const rows: Row[] = [
{ id: 1, item: 'Design', week: '2026-W02', hours: 12 },
{ id: 2, item: 'Develop', week: '2026-W10', hours: 40 },
{ id: 3, item: 'Test', week: '2026-W26', hours: 24 },
{ id: 4, item: 'Release', week: '2026-W47', hours: 8 },
{ id: 5, item: 'Undecided', week: null, hours: 0 },
];
// The filter cell of the week column accepts a week picked with the calendar button, or typed text like >=2026-W10 or 2026-W01..2026-W26.
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 130 },
{
id: 'week',
title: 'Work week',
kind: 'week',
width: 170,
editable: true,
filter: {},
},
{ id: 'hours', title: 'Hours', kind: 'number', width: 100, align: 'end' },
],
filterRow: true,
rows,
rowKey: 'id',
ariaLabel: 'Week filter and export',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Use the calendar button in the week filter cell, or type something like >=2026-W10.');
}
export const actions = {
fromW10: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'gte', value: '2026-W10' }],
});
say('Kept 2026-W10 and later.');
},
firstHalf: (api: GridApi<Row>) => {
api.setFilterModel({
match: 'all',
items: [{ columnId: 'week', operator: 'between', value: ['2026-W01', '2026-W26'] }],
});
say('Kept 2026-W01 to 2026-W26.');
},
clear: (api: GridApi<Row>) => api.setFilterModel(null),
csv: (api: GridApi<Row>) => {
const text = exportCsv(api, { bom: false, newline: '\n' });
say(`CSV (visible rows): ${text.trim().split('\n').slice(1).join(' | ')}`);
},
};