날짜 칸 편집: 직접 쓰거나 달력에서 고르기Edit dates by typing or from a calendar
날짜 컬럼은 날짜 편집기가 열려요. 2026-03-05나 2026.3.5처럼 직접 쓰거나 달력에서 고를 수 있고, 값은 데이터에 들어 있던 모양(Date·글자·밀리초) 그대로 돌아와요.Date columns open a date editor: type 2026-03-05 or 2026.3.5, or pick from the calendar. The value comes back in the shape it had (Date, text or milliseconds).
코드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="openCalendar">첫 줄 마감일 편집</button>
</div>
<div id="grid" style="height: 280px"></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('openCalendar').addEventListener('click', () => actions.openCalendar(api));// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
const tasks = ['계약서 검토', '디자인 시안 확인', '예산안 제출', '교육 자료 배포'];
// 날짜 컬럼(kind: 'date')은 날짜 편집기가 열려요. 같은 날짜라도 데이터에 어떤 모양으로 들어 있든 그 모양 그대로 돌려줘요:
// Date 객체는 Date로, 'YYYY-MM-DD' 글자는 글자로, 밀리초 숫자는 숫자로 돌아와요. 날짜는 로컬 달력 날짜라서 시간대 때문에 하루가 밀리지 않아요.
const rows = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options = {
columns: [
{ id: 'task', title: '업무', width: 150 },
{
id: 'due',
title: '마감일 (Date)',
kind: 'date',
width: 150,
editable: true,
validation: {
required: true,
custom: (value) => value instanceof Date && value < new Date(2026, 0, 1)
? L('2026년 이후 날짜를 골라 주세요.', 'Pick a date in 2026 or later.')
: null,
},
},
{ id: 'received', title: '접수일 (글자)', kind: 'date', width: 150, editable: true },
{ id: 'updated', title: '수정일 (밀리초)', kind: 'date', width: 150, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api, log) {
log({
ko: '날짜 칸을 더블클릭하세요. 2026-03-05, 2026.3.5, 20260305처럼 직접 써도 돼요.',
en: 'Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.',
});
const kinds = {
due: 'Date 객체',
received: '글자',
updated: '숫자(밀리초)',
};
const title = (id) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) => log({
ko: `${e.rowKey}번 줄 ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
})),
api.on('validationFailed', (e) => log({ ko: `확정하지 못했어요: ${e.message}`, en: `Could not confirm: ${e.message}` })),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api) => api.startEdit(1, 'due'),
};<!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="openCalendar">첫 줄 마감일 편집</button>
</div>
<div id="grid" style="height: 280px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
const tasks = ['계약서 검토', '디자인 시안 확인', '예산안 제출', '교육 자료 배포'];
// 날짜 컬럼(kind: 'date')은 날짜 편집기가 열려요. 같은 날짜라도 데이터에 어떤 모양으로 들어 있든 그 모양 그대로 돌려줘요:
// Date 객체는 Date로, 'YYYY-MM-DD' 글자는 글자로, 밀리초 숫자는 숫자로 돌아와요. 날짜는 로컬 달력 날짜라서 시간대 때문에 하루가 밀리지 않아요.
const rows = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
const options = {
columns: [
{ id: 'task', title: '업무', width: 150 },
{
id: 'due',
title: '마감일 (Date)',
kind: 'date',
width: 150,
editable: true,
validation: {
required: true,
custom: (value) => value instanceof Date && value < new Date(2026, 0, 1)
? L('2026년 이후 날짜를 골라 주세요.', 'Pick a date in 2026 or later.')
: null,
},
},
{ id: 'received', title: '접수일 (글자)', kind: 'date', width: 150, editable: true },
{ id: 'updated', title: '수정일 (밀리초)', kind: 'date', width: 150, editable: true },
],
rows,
rowKey: 'id',
};
function setup(api, log) {
log({
ko: '날짜 칸을 더블클릭하세요. 2026-03-05, 2026.3.5, 20260305처럼 직접 써도 돼요.',
en: 'Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.',
});
const kinds = {
due: 'Date 객체',
received: '글자',
updated: '숫자(밀리초)',
};
const title = (id) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) => log({
ko: `${e.rowKey}번 줄 ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
})),
api.on('validationFailed', (e) => log({ ko: `확정하지 못했어요: ${e.message}`, en: `Could not confirm: ${e.message}` })),
];
return () => offs.forEach((off) => off());
}
const actions = {
openCalendar: (api) => api.startEdit(1, 'due'),
};
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('openCalendar').addEventListener('click', () => actions.openCalendar(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.openCalendar(api)}
>첫 줄 마감일 편집</button>
</div>
<Grid style={{ height: 280 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = ['계약서 검토', '디자인 시안 확인', '예산안 제출', '교육 자료 배포'];
// 날짜 컬럼(kind: 'date')은 날짜 편집기가 열려요. 같은 날짜라도 데이터에 어떤 모양으로 들어 있든 그 모양 그대로 돌려줘요:
// Date 객체는 Date로, 'YYYY-MM-DD' 글자는 글자로, 밀리초 숫자는 숫자로 돌아와요. 날짜는 로컬 달력 날짜라서 시간대 때문에 하루가 밀리지 않아요.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 150 },
{
id: 'due',
title: '마감일 (Date)',
kind: 'date',
width: 150,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? L('2026년 이후 날짜를 골라 주세요.', 'Pick a date in 2026 or later.')
: null,
},
},
{ id: 'received', title: '접수일 (글자)', kind: 'date', width: 150, editable: true },
{ id: 'updated', title: '수정일 (밀리초)', kind: 'date', width: 150, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '날짜 칸을 더블클릭하세요. 2026-03-05, 2026.3.5, 20260305처럼 직접 써도 돼요.',
en: 'Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.',
});
const kinds: Record<string, string> = {
due: 'Date 객체',
received: '글자',
updated: '숫자(밀리초)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 줄 ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
}),
),
api.on('validationFailed', (e) =>
log({ ko: `확정하지 못했어요: ${e.message}`, en: `Could not confirm: ${e.message}` }),
),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};버튼을 누르면 이 예제의 코드가 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.openCalendar(api)"
>첫 줄 마감일 편집</button>
</div>
<Grid style="height: 280px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = ['계약서 검토', '디자인 시안 확인', '예산안 제출', '교육 자료 배포'];
// 날짜 컬럼(kind: 'date')은 날짜 편집기가 열려요. 같은 날짜라도 데이터에 어떤 모양으로 들어 있든 그 모양 그대로 돌려줘요:
// Date 객체는 Date로, 'YYYY-MM-DD' 글자는 글자로, 밀리초 숫자는 숫자로 돌아와요. 날짜는 로컬 달력 날짜라서 시간대 때문에 하루가 밀리지 않아요.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 150 },
{
id: 'due',
title: '마감일 (Date)',
kind: 'date',
width: 150,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? L('2026년 이후 날짜를 골라 주세요.', 'Pick a date in 2026 or later.')
: null,
},
},
{ id: 'received', title: '접수일 (글자)', kind: 'date', width: 150, editable: true },
{ id: 'updated', title: '수정일 (밀리초)', kind: 'date', width: 150, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '날짜 칸을 더블클릭하세요. 2026-03-05, 2026.3.5, 20260305처럼 직접 써도 돼요.',
en: 'Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.',
});
const kinds: Record<string, string> = {
due: 'Date 객체',
received: '글자',
updated: '숫자(밀리초)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 줄 ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
}),
),
api.on('validationFailed', (e) =>
log({ ko: `확정하지 못했어요: ${e.message}`, en: `Could not confirm: ${e.message}` }),
),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};버튼을 누르면 이 예제의 코드가 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.openCalendar(api)"
>첫 줄 마감일 편집</button>
</div>
<mx-grid style="height: 280px" [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 { GridApi, GridOptions } from '@maxgrid/angular';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = ['계약서 검토', '디자인 시안 확인', '예산안 제출', '교육 자료 배포'];
// 날짜 컬럼(kind: 'date')은 날짜 편집기가 열려요. 같은 날짜라도 데이터에 어떤 모양으로 들어 있든 그 모양 그대로 돌려줘요:
// Date 객체는 Date로, 'YYYY-MM-DD' 글자는 글자로, 밀리초 숫자는 숫자로 돌아와요. 날짜는 로컬 달력 날짜라서 시간대 때문에 하루가 밀리지 않아요.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 150 },
{
id: 'due',
title: '마감일 (Date)',
kind: 'date',
width: 150,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? L('2026년 이후 날짜를 골라 주세요.', 'Pick a date in 2026 or later.')
: null,
},
},
{ id: 'received', title: '접수일 (글자)', kind: 'date', width: 150, editable: true },
{ id: 'updated', title: '수정일 (밀리초)', kind: 'date', width: 150, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '날짜 칸을 더블클릭하세요. 2026-03-05, 2026.3.5, 20260305처럼 직접 써도 돼요.',
en: 'Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.',
});
const kinds: Record<string, string> = {
due: 'Date 객체',
received: '글자',
updated: '숫자(밀리초)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 줄 ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
}),
),
api.on('validationFailed', (e) =>
log({ ko: `확정하지 못했어요: ${e.message}`, en: `Could not confirm: ${e.message}` }),
),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};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="openCalendar">Edit first due date</button>
</div>
<div id="grid" style="height: 280px"></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('openCalendar').addEventListener('click', () => actions.openCalendar(api));const tasks = [
'Review contract',
'Check design draft',
'Submit budget',
'Distribute training material',
];
// A date column (kind: 'date') opens a date editor. Whatever shape the date has in the data, it comes back in that shape:
// a Date object returns as a Date, a 'YYYY-MM-DD' string as a string, and a millisecond number as a number. Dates are local calendar dates, so a time zone never shifts them by a day.
const rows = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{
id: 'due',
title: 'Due date (Date)',
kind: 'date',
width: 160,
editable: true,
validation: {
required: true,
custom: (value) => value instanceof Date && value < new Date(2026, 0, 1)
? 'Pick a date in 2026 or later.'
: null,
},
},
{ id: 'received', title: 'Received (string)', kind: 'date', width: 160, editable: true },
{ id: 'updated', title: 'Updated (milliseconds)', kind: 'date', width: 180, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api, log) {
log('Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.');
const kinds = {
due: 'Date object',
received: 'string',
updated: 'number (milliseconds)',
};
const title = (id) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api) => api.startEdit(1, 'due'),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Edit dates by typing or from a calendar</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="openCalendar">Edit first due date</button>
</div>
<div id="grid" style="height: 280px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const tasks = [
'Review contract',
'Check design draft',
'Submit budget',
'Distribute training material',
];
// A date column (kind: 'date') opens a date editor. Whatever shape the date has in the data, it comes back in that shape:
// a Date object returns as a Date, a 'YYYY-MM-DD' string as a string, and a millisecond number as a number. Dates are local calendar dates, so a time zone never shifts them by a day.
const rows = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
const options = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{
id: 'due',
title: 'Due date (Date)',
kind: 'date',
width: 160,
editable: true,
validation: {
required: true,
custom: (value) => value instanceof Date && value < new Date(2026, 0, 1)
? 'Pick a date in 2026 or later.'
: null,
},
},
{ id: 'received', title: 'Received (string)', kind: 'date', width: 160, editable: true },
{ id: 'updated', title: 'Updated (milliseconds)', kind: 'date', width: 180, editable: true },
],
rows,
rowKey: 'id',
};
function setup(api, log) {
log('Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.');
const kinds = {
due: 'Date object',
received: 'string',
updated: 'number (milliseconds)',
};
const title = (id) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
const actions = {
openCalendar: (api) => api.startEdit(1, 'due'),
};
options.ariaLabel = "Edit dates by typing or from a calendar";
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('openCalendar').addEventListener('click', () => actions.openCalendar(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.openCalendar(api)}
>Edit first due date</button>
</div>
<Grid style={{ height: 280 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = [
'Review contract',
'Check design draft',
'Submit budget',
'Distribute training material',
];
// A date column (kind: 'date') opens a date editor. Whatever shape the date has in the data, it comes back in that shape:
// a Date object returns as a Date, a 'YYYY-MM-DD' string as a string, and a millisecond number as a number. Dates are local calendar dates, so a time zone never shifts them by a day.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{
id: 'due',
title: 'Due date (Date)',
kind: 'date',
width: 160,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? 'Pick a date in 2026 or later.'
: null,
},
},
{ id: 'received', title: 'Received (string)', kind: 'date', width: 160, editable: true },
{ id: 'updated', title: 'Updated (milliseconds)', kind: 'date', width: 180, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.');
const kinds: Record<string, string> = {
due: 'Date object',
received: 'string',
updated: 'number (milliseconds)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log(
`Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
),
),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};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.openCalendar(api)"
>Edit first due date</button>
</div>
<Grid style="height: 280px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = [
'Review contract',
'Check design draft',
'Submit budget',
'Distribute training material',
];
// A date column (kind: 'date') opens a date editor. Whatever shape the date has in the data, it comes back in that shape:
// a Date object returns as a Date, a 'YYYY-MM-DD' string as a string, and a millisecond number as a number. Dates are local calendar dates, so a time zone never shifts them by a day.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{
id: 'due',
title: 'Due date (Date)',
kind: 'date',
width: 160,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? 'Pick a date in 2026 or later.'
: null,
},
},
{ id: 'received', title: 'Received (string)', kind: 'date', width: 160, editable: true },
{ id: 'updated', title: 'Updated (milliseconds)', kind: 'date', width: 180, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.');
const kinds: Record<string, string> = {
due: 'Date object',
received: 'string',
updated: 'number (milliseconds)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log(
`Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
),
),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};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.openCalendar(api)"
>Edit first due date</button>
</div>
<mx-grid style="height: 280px" [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 { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
due: Date;
received: string;
updated: number;
}
const tasks = [
'Review contract',
'Check design draft',
'Submit budget',
'Distribute training material',
];
// A date column (kind: 'date') opens a date editor. Whatever shape the date has in the data, it comes back in that shape:
// a Date object returns as a Date, a 'YYYY-MM-DD' string as a string, and a millisecond number as a number. Dates are local calendar dates, so a time zone never shifts them by a day.
const rows: Row[] = tasks.map((task, i) => {
const date = new Date(2026, 2 + i, 5 + i * 3);
const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
return { id: i + 1, task, due: date, received: iso, updated: date.getTime() };
});
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{
id: 'due',
title: 'Due date (Date)',
kind: 'date',
width: 160,
editable: true,
validation: {
required: true,
custom: (value) =>
value instanceof Date && value < new Date(2026, 0, 1)
? 'Pick a date in 2026 or later.'
: null,
},
},
{ id: 'received', title: 'Received (string)', kind: 'date', width: 160, editable: true },
{ id: 'updated', title: 'Updated (milliseconds)', kind: 'date', width: 180, editable: true },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click a date cell. You can also type it directly: 2026-03-05, 2026.3.5 or 20260305.');
const kinds: Record<string, string> = {
due: 'Date object',
received: 'string',
updated: 'number (milliseconds)',
};
const title = (id: string) => api.getColumns().find((c) => c.id === id)?.title ?? id;
const offs = [
api.on('editCommitted', (e) =>
log(
`Row ${e.rowKey} ${title(e.columnId)} → ${kinds[e.columnId] ?? ''}: ${String(e.newValue)}`,
),
),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openCalendar: (api: GridApi<Row>) => api.startEdit(1, 'due'),
};