날짜와 시간을 한 번에 고르기Pick a date and a time together
날짜+시간 컬럼(kind: datetime)을 고치면 달력과 시·분 목록이 함께 열리고 '확인'으로 한 번에 정해요. 저장되는 값은 'YYYY-MM-DD HH:mm' 글자 하나예요.Editing a datetime column opens a calendar and time lists together, and OK sets both at once. The stored value is one 'YYYY-MM-DD HH:mm' string.
코드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="edit">첫 줄 편집</button>
<select aria-label="시간 표시" id="clock">
<option value="auto" selected>언어 기본</option>
<option value="24">24시간</option>
<option value="12">오전·오후</option>
</select>
</div>
<div id="grid" style="height: 340px"></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('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('clock').addEventListener('change', (event) => actions.clock(api, event.target.value));// 예제 틀이 알려 주는 페이지 언어(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' 문자열이에요. 정렬·필터·내보내기도 이 값 기준이에요.
// hour12를 생략하면 언어를 따라요(한국어는 오전·오후). 저장되는 값은 항상 24시간이에요.
const columns = (hour12) => [
{ id: 'event', title: '일정', width: 140 },
{
id: 'at',
title: '시작',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // 점심시간은 못 골라요
},
},
];
export const options = {
columns: columns(undefined),
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00' },
{ id: 2, event: '고객 미팅', at: '2026-11-11 14:30' },
{ id: 3, event: '코드 리뷰', at: '2026-11-12 16:05' },
{ id: 4, event: '배포', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(api, log) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const fail = api.on('validationFailed', ({ message }) => log(message));
const stop = followPageLanguage(api);
return () => {
off();
fail();
stop();
};
}
export const actions = {
edit: (api) => api.startEdit(1, 'at'),
clock: (api, value) => api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};<!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="edit">첫 줄 편집</button>
<select aria-label="시간 표시" id="clock">
<option value="auto" selected>언어 기본</option>
<option value="24">24시간</option>
<option value="12">오전·오후</option>
</select>
</div>
<div id="grid" style="height: 340px"></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' 문자열이에요. 정렬·필터·내보내기도 이 값 기준이에요.
// hour12를 생략하면 언어를 따라요(한국어는 오전·오후). 저장되는 값은 항상 24시간이에요.
const columns = (hour12) => [
{ id: 'event', title: '일정', width: 140 },
{
id: 'at',
title: '시작',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // 점심시간은 못 골라요
},
},
];
const options = {
columns: columns(undefined),
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00' },
{ id: 2, event: '고객 미팅', at: '2026-11-11 14:30' },
{ id: 3, event: '코드 리뷰', at: '2026-11-12 16:05' },
{ id: 4, event: '배포', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: pageLang(),
};
function setup(api, log) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const fail = api.on('validationFailed', ({ message }) => log(message));
const stop = followPageLanguage(api);
return () => {
off();
fail();
stop();
};
}
const actions = {
edit: (api) => api.startEdit(1, 'at'),
clock: (api, value) => api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};
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('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('clock').addEventListener('change', (event) => actions.clock(api, event.target.value));
</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.edit(api)}
>첫 줄 편집</button>
<select
aria-label="시간 표시"
disabled={!api}
onChange={(event) => api && actions.clock(api, event.target.value)}
>
<option value="auto">언어 기본</option>
<option value="24">24시간</option>
<option value="12">오전·오후</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
event: string;
at: 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' 문자열이에요. 정렬·필터·내보내기도 이 값 기준이에요.
// hour12를 생략하면 언어를 따라요(한국어는 오전·오후). 저장되는 값은 항상 24시간이에요.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: '일정', width: 140 },
{
id: 'at',
title: '시작',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // 점심시간은 못 골라요
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00' },
{ id: 2, event: '고객 미팅', at: '2026-11-11 14:30' },
{ id: 3, event: '코드 리뷰', at: '2026-11-12 16:05' },
{ id: 4, event: '배포', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
const stop = followPageLanguage(api);
return () => {
off();
fail();
stop();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};버튼을 누르면 이 예제의 코드가 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.edit(api)">첫 줄 편집</button>
<select
aria-label="시간 표시"
:disabled="!api"
@change="api && actions.clock(api, ($event.target as HTMLSelectElement).value)"
>
<option value="auto" selected>언어 기본</option>
<option value="24">24시간</option>
<option value="12">오전·오후</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
event: string;
at: 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' 문자열이에요. 정렬·필터·내보내기도 이 값 기준이에요.
// hour12를 생략하면 언어를 따라요(한국어는 오전·오후). 저장되는 값은 항상 24시간이에요.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: '일정', width: 140 },
{
id: 'at',
title: '시작',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // 점심시간은 못 골라요
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00' },
{ id: 2, event: '고객 미팅', at: '2026-11-11 14:30' },
{ id: 3, event: '코드 리뷰', at: '2026-11-12 16:05' },
{ id: 4, event: '배포', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
const stop = followPageLanguage(api);
return () => {
off();
fail();
stop();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};버튼을 누르면 이 예제의 코드가 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.edit(api)"
>첫 줄 편집</button>
<select
aria-label="시간 표시"
[disabled]="!api"
(change)="api && actions.clock(api, $any($event.target).value)"
>
<option value="auto" selected>언어 기본</option>
<option value="24">24시간</option>
<option value="12">오전·오후</option>
</select>
</div>
<mx-grid style="height: 340px" [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 { ColumnDef, GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
event: string;
at: 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' 문자열이에요. 정렬·필터·내보내기도 이 값 기준이에요.
// hour12를 생략하면 언어를 따라요(한국어는 오전·오후). 저장되는 값은 항상 24시간이에요.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: '일정', width: 140 },
{
id: 'at',
title: '시작',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // 점심시간은 못 골라요
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: '주간 회의', at: '2026-11-10 10:00' },
{ id: 2, event: '고객 미팅', at: '2026-11-11 14:30' },
{ id: 3, event: '코드 리뷰', at: '2026-11-12 16:05' },
{ id: 4, event: '배포', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
const stop = followPageLanguage(api);
return () => {
off();
fail();
stop();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};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="edit">Edit first row</button>
<select aria-label="Clock" id="clock">
<option value="auto" selected>Language default</option>
<option value="24">24-hour</option>
<option value="12">AM/PM</option>
</select>
</div>
<div id="grid" style="height: 340px"></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('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('clock').addEventListener('change', (event) => actions.clock(api, event.target.value));// The value is a 'YYYY-MM-DD HH:mm' string without a time zone. Sorting, filtering and export also use this value.
// If hour12 is omitted it follows the language (English uses AM/PM). The stored value is always 24-hour.
const columns = (hour12) => [
{ id: 'event', title: 'Event', width: 140 },
{
id: 'at',
title: 'Start',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // Lunch hour cannot be picked
},
},
];
export const options = {
columns: columns(undefined),
rows: [
{ id: 1, event: 'Weekly meeting', at: '2026-11-10 10:00' },
{ id: 2, event: 'Client meeting', at: '2026-11-11 14:30' },
{ id: 3, event: 'Code review', at: '2026-11-12 16:05' },
{ id: 4, event: 'Release', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: 'en',
};
export function setup(api, log) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const fail = api.on('validationFailed', ({ message }) => log(message));
return () => {
off();
fail();
};
}
export const actions = {
edit: (api) => api.startEdit(1, 'at'),
clock: (api, value) => api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pick a date and a time together</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="edit">Edit first row</button>
<select aria-label="Clock" id="clock">
<option value="auto" selected>Language default</option>
<option value="24">24-hour</option>
<option value="12">AM/PM</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// The value is a 'YYYY-MM-DD HH:mm' string without a time zone. Sorting, filtering and export also use this value.
// If hour12 is omitted it follows the language (English uses AM/PM). The stored value is always 24-hour.
const columns = (hour12) => [
{ id: 'event', title: 'Event', width: 140 },
{
id: 'at',
title: 'Start',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // Lunch hour cannot be picked
},
},
];
const options = {
columns: columns(undefined),
rows: [
{ id: 1, event: 'Weekly meeting', at: '2026-11-10 10:00' },
{ id: 2, event: 'Client meeting', at: '2026-11-11 14:30' },
{ id: 3, event: 'Code review', at: '2026-11-12 16:05' },
{ id: 4, event: 'Release', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: 'en',
};
function setup(api, log) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const fail = api.on('validationFailed', ({ message }) => log(message));
return () => {
off();
fail();
};
}
const actions = {
edit: (api) => api.startEdit(1, 'at'),
clock: (api, value) => api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};
options.ariaLabel = "Pick a date and a time together";
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('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('clock').addEventListener('change', (event) => actions.clock(api, event.target.value));
</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.edit(api)}
>Edit first row</button>
<select
aria-label="Clock"
disabled={!api}
onChange={(event) => api && actions.clock(api, event.target.value)}
>
<option value="auto">Language default</option>
<option value="24">24-hour</option>
<option value="12">AM/PM</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
event: string;
at: string;
}
// The value is a 'YYYY-MM-DD HH:mm' string without a time zone. Sorting, filtering and export also use this value.
// If hour12 is omitted it follows the language (English uses AM/PM). The stored value is always 24-hour.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: 'Event', width: 140 },
{
id: 'at',
title: 'Start',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // Lunch hour cannot be picked
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: 'Weekly meeting', at: '2026-11-10 10:00' },
{ id: 2, event: 'Client meeting', at: '2026-11-11 14:30' },
{ id: 3, event: 'Code review', at: '2026-11-12 16:05' },
{ id: 4, event: 'Release', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: 'en',
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
return () => {
off();
fail();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};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.edit(api)">Edit first row</button>
<select
aria-label="Clock"
:disabled="!api"
@change="api && actions.clock(api, ($event.target as HTMLSelectElement).value)"
>
<option value="auto" selected>Language default</option>
<option value="24">24-hour</option>
<option value="12">AM/PM</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
event: string;
at: string;
}
// The value is a 'YYYY-MM-DD HH:mm' string without a time zone. Sorting, filtering and export also use this value.
// If hour12 is omitted it follows the language (English uses AM/PM). The stored value is always 24-hour.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: 'Event', width: 140 },
{
id: 'at',
title: 'Start',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // Lunch hour cannot be picked
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: 'Weekly meeting', at: '2026-11-10 10:00' },
{ id: 2, event: 'Client meeting', at: '2026-11-11 14:30' },
{ id: 3, event: 'Code review', at: '2026-11-12 16:05' },
{ id: 4, event: 'Release', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: 'en',
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
return () => {
off();
fail();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};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.edit(api)"
>Edit first row</button>
<select
aria-label="Clock"
[disabled]="!api"
(change)="api && actions.clock(api, $any($event.target).value)"
>
<option value="auto" selected>Language default</option>
<option value="24">24-hour</option>
<option value="12">AM/PM</option>
</select>
</div>
<mx-grid style="height: 340px" [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 { ColumnDef, GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
event: string;
at: string;
}
// The value is a 'YYYY-MM-DD HH:mm' string without a time zone. Sorting, filtering and export also use this value.
// If hour12 is omitted it follows the language (English uses AM/PM). The stored value is always 24-hour.
const columns = (hour12: boolean | undefined): ColumnDef<Row>[] => [
{ id: 'event', title: 'Event', width: 140 },
{
id: 'at',
title: 'Start',
kind: 'datetime',
width: 190,
editable: true,
dateTime: {
step: 5,
min: '2026-01-01 08:00',
hour12,
isTimeDisabled: (time) => time >= '12:00' && time < '13:00', // Lunch hour cannot be picked
},
},
];
export const options: GridOptions<Row> = {
columns: columns(undefined),
rows: [
{ id: 1, event: 'Weekly meeting', at: '2026-11-10 10:00' },
{ id: 2, event: 'Client meeting', at: '2026-11-11 14:30' },
{ id: 3, event: 'Code review', at: '2026-11-12 16:05' },
{ id: 4, event: 'Release', at: '2026-11-13 09:00' },
],
rowKey: 'id',
locale: 'en',
};
export function setup(api: GridApi<Row>, log: (message: string) => void) {
const off = api.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const fail = api.on('validationFailed', ({ message }) => log(message));
return () => {
off();
fail();
};
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'at'),
clock: (api: GridApi<Row>, value?: string) =>
api.setColumns(columns(value === 'auto' ? undefined : value === '12')),
};