날짜·시각 표시 패턴 정하기Set the date and time display pattern
format.date.pattern으로 날짜와 시각이 보이는 모양을 정해요. 토큰은 YYYY YY MM M DD D HH H mm ss A예요. 값은 그대로라 편집기·정렬·내보내기에는 영향이 없어요.format.date.pattern sets how dates and times look. Tokens are YYYY YY MM M DD D HH H mm ss A. The value stays the same, so the editor, sort and export are unaffected.
코드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="pattern24">24시간 패턴</button>
<button type="button" id="reset">처음 패턴</button>
</div>
<div id="grid" style="height: 200px"></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('pattern24').addEventListener('click', () => actions.pattern24(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));const rows = [
{ id: 1, task: '설계', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: '구현', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: '검수', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern은 보이는 모양만 바꾸고 값(YYYY-MM-DD)은 그대로예요. 달력·정렬·내보내기는 표준 값을 써요.
export const options = {
columns: [
{ id: 'id', title: '번호', kind: 'number', width: 70 },
{ id: 'task', title: '작업', width: 100 },
{
id: 'due',
title: '마감',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'YYYY.MM.DD' } },
},
{
id: 'at',
title: '시각',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H시' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api, log) {
log({
ko: '시각 패턴의 A는 언어에 맞는 오전·오후예요(24시간 토큰은 H, HH).',
en: 'A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).',
});
return () => undefined;
}
export const actions = {
pattern24: (api) => api.setColumns(options.columns.map((c) => c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c)),
reset: (api) => api.setColumns(options.columns),
};<!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="pattern24">24시간 패턴</button>
<button type="button" id="reset">처음 패턴</button>
</div>
<div id="grid" style="height: 200px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = [
{ id: 1, task: '설계', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: '구현', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: '검수', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern은 보이는 모양만 바꾸고 값(YYYY-MM-DD)은 그대로예요. 달력·정렬·내보내기는 표준 값을 써요.
const options = {
columns: [
{ id: 'id', title: '번호', kind: 'number', width: 70 },
{ id: 'task', title: '작업', width: 100 },
{
id: 'due',
title: '마감',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'YYYY.MM.DD' } },
},
{
id: 'at',
title: '시각',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H시' } },
},
],
rows,
rowKey: 'id',
};
function setup(_api, log) {
log({
ko: '시각 패턴의 A는 언어에 맞는 오전·오후예요(24시간 토큰은 H, HH).',
en: 'A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).',
});
return () => undefined;
}
const actions = {
pattern24: (api) => api.setColumns(options.columns.map((c) => c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c)),
reset: (api) => api.setColumns(options.columns),
};
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('pattern24').addEventListener('click', () => actions.pattern24(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(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.pattern24(api)}
>24시간 패턴</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reset(api)}
>처음 패턴</button>
</div>
<Grid style={{ height: 200 }} 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: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: '설계', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: '구현', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: '검수', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern은 보이는 모양만 바꾸고 값(YYYY-MM-DD)은 그대로예요. 달력·정렬·내보내기는 표준 값을 써요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '번호', kind: 'number', width: 70 },
{ id: 'task', title: '작업', width: 100 },
{
id: 'due',
title: '마감',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'YYYY.MM.DD' } },
},
{
id: 'at',
title: '시각',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H시' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '시각 패턴의 A는 언어에 맞는 오전·오후예요(24시간 토큰은 H, HH).',
en: 'A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).',
});
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};버튼을 누르면 이 예제의 코드가 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.pattern24(api)"
>24시간 패턴</button>
<button type="button" :disabled="!api" @click="api && actions.reset(api)">처음 패턴</button>
</div>
<Grid style="height: 200px" :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: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: '설계', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: '구현', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: '검수', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern은 보이는 모양만 바꾸고 값(YYYY-MM-DD)은 그대로예요. 달력·정렬·내보내기는 표준 값을 써요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '번호', kind: 'number', width: 70 },
{ id: 'task', title: '작업', width: 100 },
{
id: 'due',
title: '마감',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'YYYY.MM.DD' } },
},
{
id: 'at',
title: '시각',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H시' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '시각 패턴의 A는 언어에 맞는 오전·오후예요(24시간 토큰은 H, HH).',
en: 'A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).',
});
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};버튼을 누르면 이 예제의 코드가 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.pattern24(api)"
>24시간 패턴</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reset(api)"
>처음 패턴</button>
</div>
<mx-grid style="height: 200px" [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: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: '설계', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: '구현', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: '검수', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern은 보이는 모양만 바꾸고 값(YYYY-MM-DD)은 그대로예요. 달력·정렬·내보내기는 표준 값을 써요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '번호', kind: 'number', width: 70 },
{ id: 'task', title: '작업', width: 100 },
{
id: 'due',
title: '마감',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'YYYY.MM.DD' } },
},
{
id: 'at',
title: '시각',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H시' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '시각 패턴의 A는 언어에 맞는 오전·오후예요(24시간 토큰은 H, HH).',
en: 'A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).',
});
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};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="pattern24">24-hour pattern</button>
<button type="button" id="reset">Original pattern</button>
</div>
<div id="grid" style="height: 200px"></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('pattern24').addEventListener('click', () => actions.pattern24(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));const rows = [
{ id: 1, task: 'Design', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: 'Build', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: 'Review', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern only changes the displayed shape; the value (YYYY-MM-DD) stays the same. Calendar, sort and export use the standard value.
export const options = {
columns: [
{ id: 'id', title: 'No.', kind: 'number', width: 70 },
{ id: 'task', title: 'Task', width: 100 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'MM/DD/YYYY' } },
},
{
id: 'at',
title: 'Time',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H:mm' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api, log) {
log('A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).');
return () => undefined;
}
export const actions = {
pattern24: (api) => api.setColumns(options.columns.map((c) => c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c)),
reset: (api) => api.setColumns(options.columns),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Set the date and time display pattern</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="pattern24">24-hour pattern</button>
<button type="button" id="reset">Original pattern</button>
</div>
<div id="grid" style="height: 200px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = [
{ id: 1, task: 'Design', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: 'Build', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: 'Review', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern only changes the displayed shape; the value (YYYY-MM-DD) stays the same. Calendar, sort and export use the standard value.
const options = {
columns: [
{ id: 'id', title: 'No.', kind: 'number', width: 70 },
{ id: 'task', title: 'Task', width: 100 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'MM/DD/YYYY' } },
},
{
id: 'at',
title: 'Time',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H:mm' } },
},
],
rows,
rowKey: 'id',
};
function setup(_api, log) {
log('A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).');
return () => undefined;
}
const actions = {
pattern24: (api) => api.setColumns(options.columns.map((c) => c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c)),
reset: (api) => api.setColumns(options.columns),
};
options.ariaLabel = "Set the date and time display pattern";
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('pattern24').addEventListener('click', () => actions.pattern24(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(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.pattern24(api)}
>24-hour pattern</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reset(api)}
>Original pattern</button>
</div>
<Grid style={{ height: 200 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
task: string;
due: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: 'Design', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: 'Build', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: 'Review', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern only changes the displayed shape; the value (YYYY-MM-DD) stays the same. Calendar, sort and export use the standard value.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: 'No.', kind: 'number', width: 70 },
{ id: 'task', title: 'Task', width: 100 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'MM/DD/YYYY' } },
},
{
id: 'at',
title: 'Time',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H:mm' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log('A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).');
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};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.pattern24(api)"
>24-hour pattern</button>
<button type="button" :disabled="!api" @click="api && actions.reset(api)">Original pattern</button>
</div>
<Grid style="height: 200px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
task: string;
due: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: 'Design', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: 'Build', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: 'Review', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern only changes the displayed shape; the value (YYYY-MM-DD) stays the same. Calendar, sort and export use the standard value.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: 'No.', kind: 'number', width: 70 },
{ id: 'task', title: 'Task', width: 100 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'MM/DD/YYYY' } },
},
{
id: 'at',
title: 'Time',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H:mm' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log('A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).');
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};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.pattern24(api)"
>24-hour pattern</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reset(api)"
>Original pattern</button>
</div>
<mx-grid style="height: 200px" [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;
export interface Row {
id: number;
task: string;
due: string;
at: string;
}
const rows: Row[] = [
{ id: 1, task: 'Design', due: '2026-03-05', at: '2026-03-05 09:30' },
{ id: 2, task: 'Build', due: '2024-02-29', at: '2024-02-29 14:05' },
{ id: 3, task: 'Review', due: '2026-12-31', at: '2026-12-31 23:59' },
];
// format.date.pattern only changes the displayed shape; the value (YYYY-MM-DD) stays the same. Calendar, sort and export use the standard value.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: 'No.', kind: 'number', width: 70 },
{ id: 'task', title: 'Task', width: 100 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 150,
editable: true,
format: { date: { pattern: 'MM/DD/YYYY' } },
},
{
id: 'at',
title: 'Time',
kind: 'datetime',
width: 190,
editable: true,
format: { date: { pattern: 'M/D A H:mm' } },
},
],
rows,
rowKey: 'id',
};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
log('A in the pattern is the AM/PM text of the locale (24-hour tokens are H and HH).');
return () => undefined;
}
export const actions = {
pattern24: (api: GridApi<Row>) =>
api.setColumns(
options.columns.map((c) =>
c.id === 'at' ? { ...c, format: { date: { pattern: 'YYYY-MM-DD HH:mm' } } } : c,
),
),
reset: (api: GridApi<Row>) => api.setColumns(options.columns),
};