본문으로 건너뛰기Skip to content
예제 첫화면Examples home

달 컬럼 필터와 내보내기Filter and export a month column

달 컬럼(kind: 'month')은 필터 칸에서 달 패널로 고르거나 >=2026-06 처럼 쓸 수 있고, 내보내기에는 YYYY-MM 글자로 나가요(xlsx는 yyyy-mm 서식의 날짜 셀).A month column (kind: 'month') can be filtered by picking from a month panel or typing >=2026-06, and exports as YYYY-MM text (a yyyy-mm date cell in xlsx).

활용Intermediate
직접 써 보기Live preview달 컬럼 필터와 내보내기Filter and export a month column

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/export로 설치하세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<div id="app">
  <div class="toolbar">
    <button type="button" id="fromJune">2026-06 이후</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>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('fromJune').addEventListener('click', () => actions.fromJune(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));
example.js
import { exportCsv } from '@maxgrid/export';
const rows = [
  { id: 1, item: '임대료', month: '2026-01', amount: 900 },
  { id: 2, item: '전기료', month: '2026-03', amount: 140 },
  { id: 3, item: '구독료', month: '2026-06', amount: 60 },
  { id: 4, item: '보험료', month: '2026-11', amount: 320 },
  { id: 5, item: '미정', month: null, amount: 0 },
];
// 달 컬럼의 필터 칸은 달력 단추로 월 패널을 열고, 2026-03 · >=2026-06 · 2026-01..2026-06 처럼 써도 돼요.
export const options = {
  columns: [
    { id: 'item', title: '항목', width: 130 },
    { id: 'month', title: '청구월', kind: 'month', width: 170, editable: true, filter: {} },
    { id: 'amount', title: '금액', kind: 'number', width: 100, align: 'end' },
  ],
  filterRow: true,
  rows,
  rowKey: 'id',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  log({
    ko: '청구월 필터 칸의 달력 단추를 눌러 달을 고르거나 >=2026-06 처럼 써 보세요.',
    en: 'Use the calendar button in the month filter cell, or type something like >=2026-06.',
  });
}
export const actions = {
  fromJune: (api) => {
    api.setFilterModel({
      match: 'all',
      items: [{ columnId: 'month', operator: 'gte', value: '2026-06' }],
    });
    say({ ko: '2026-06 이후만 남겼어요.', en: 'Kept 2026-06 and later.' });
  },
  firstHalf: (api) => {
    api.setFilterModel({
      match: 'all',
      items: [{ columnId: 'month', operator: 'between', value: ['2026-01', '2026-06'] }],
    });
    say({ ko: '2026-01~2026-06만 남겼어요.', en: 'Kept 2026-01 to 2026-06.' });
  },
  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(' | ')}`,
    });
  },
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

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.

index.html
<div id="app">
  <div class="toolbar">
    <button type="button" id="fromJune">From 2026-06</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>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('fromJune').addEventListener('click', () => actions.fromJune(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));
example.js
import { exportCsv } from '@maxgrid/export';
const rows = [
  { id: 1, item: 'Rent', month: '2026-01', amount: 900 },
  { id: 2, item: 'Electricity', month: '2026-03', amount: 140 },
  { id: 3, item: 'Subscription', month: '2026-06', amount: 60 },
  { id: 4, item: 'Insurance', month: '2026-11', amount: 320 },
  { id: 5, item: 'Undecided', month: null, amount: 0 },
];
// The filter cell of the month column opens a month panel with the calendar button, or accepts typed text like 2026-03, >=2026-06 or 2026-01..2026-06.
export const options = {
  columns: [
    { id: 'item', title: 'Item', width: 130 },
    { id: 'month', title: 'Billing month', kind: 'month', width: 170, editable: true, filter: {} },
    { id: 'amount', title: 'Amount', kind: 'number', width: 100, align: 'end' },
  ],
  filterRow: true,
  rows,
  rowKey: 'id',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  log('Use the calendar button in the month filter cell, or type something like >=2026-06.');
}
export const actions = {
  fromJune: (api) => {
    api.setFilterModel({
      match: 'all',
      items: [{ columnId: 'month', operator: 'gte', value: '2026-06' }],
    });
    say('Kept 2026-06 and later.');
  },
  firstHalf: (api) => {
    api.setFilterModel({
      match: 'all',
      items: [{ columnId: 'month', operator: 'between', value: ['2026-01', '2026-06'] }],
    });
    say('Kept 2026-01 to 2026-06.');
  },
  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(' | ')}`);
  },
};