날짜 선택기 열기 방식 정하기Choose how the date picker opens
dateTime의 openOnEdit은 편집을 시작하면 선택기를 바로 열고, pickOnly는 입력칸을 읽기 전용으로 두고 선택기로만 값을 정해요. confirm은 날을 누른 뒤 확인 단추로 확정해요. startDate는 값이 없을 때 달력이 보여 줄 달이에요.openOnEdit in dateTime opens the picker as soon as editing starts, and pickOnly makes the input read-only so only the picker sets the value. confirm adds an OK step after clicking a day. startDate is the month shown when there is no value.
코드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="mode">
<option value="open" selected>바로 열기</option>
<option value="pick">선택기로만</option>
<option value="confirm">확인 단추</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('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요.
const pageLang = () => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// openOnEdit: 편집을 시작하면 선택기를 바로 열어요. pickOnly: 입력칸은 읽기 전용, 선택기로만 정해요.
// confirm: 날을 눌러도 확인(또는 Enter)을 눌러야 확정돼요. startDate: 값이 없을 때 달력이 보여 줄 날이에요.
const columns = (mode) => [
{ id: 'name', title: '업무', width: 150 },
{
id: 'due',
title: '마감일',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options = {
columns: columns('open'),
rows: [
{ id: 1, name: '디자인 검수', due: '2026-03-05' },
{ id: 2, name: '문서 정리', due: null },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(current, log) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const watcher = new MutationObserver(() => current.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => {
off();
watcher.disconnect();
};
}
export const actions = {
edit: (current) => current.startEdit(1, 'due'),
mode: (current, value) => current.setColumns(columns(value ?? 'open')),
};<!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="mode">
<option value="open" selected>바로 열기</option>
<option value="pick">선택기로만</option>
<option value="confirm">확인 단추</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');
// openOnEdit: 편집을 시작하면 선택기를 바로 열어요. pickOnly: 입력칸은 읽기 전용, 선택기로만 정해요.
// confirm: 날을 눌러도 확인(또는 Enter)을 눌러야 확정돼요. startDate: 값이 없을 때 달력이 보여 줄 날이에요.
const columns = (mode) => [
{ id: 'name', title: '업무', width: 150 },
{
id: 'due',
title: '마감일',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
const options = {
columns: columns('open'),
rows: [
{ id: 1, name: '디자인 검수', due: '2026-03-05' },
{ id: 2, name: '문서 정리', due: null },
],
rowKey: 'id',
locale: pageLang(),
};
function setup(current, log) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
const watcher = new MutationObserver(() => current.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => {
off();
watcher.disconnect();
};
}
const actions = {
edit: (current) => current.startEdit(1, 'due'),
mode: (current, value) => current.setColumns(columns(value ?? 'open')),
};
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('mode').addEventListener('change', (event) => actions.mode(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.mode(api, event.target.value)}
>
<option value="open">바로 열기</option>
<option value="pick">선택기로만</option>
<option value="confirm">확인 단추</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
due: string | null;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// openOnEdit: 편집을 시작하면 선택기를 바로 열어요. pickOnly: 입력칸은 읽기 전용, 선택기로만 정해요.
// confirm: 날을 눌러도 확인(또는 Enter)을 눌러야 확정돼요. startDate: 값이 없을 때 달력이 보여 줄 날이에요.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: '업무', width: 150 },
{
id: 'due',
title: '마감일',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: '디자인 검수', due: '2026-03-05' },
{ id: 2, name: '문서 정리', due: null },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const watcher = new MutationObserver(() => current.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => {
off();
watcher.disconnect();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};버튼을 누르면 이 예제의 코드가 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.mode(api, ($event.target as HTMLSelectElement).value)"
>
<option value="open" selected>바로 열기</option>
<option value="pick">선택기로만</option>
<option value="confirm">확인 단추</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;
name: string;
due: string | null;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// openOnEdit: 편집을 시작하면 선택기를 바로 열어요. pickOnly: 입력칸은 읽기 전용, 선택기로만 정해요.
// confirm: 날을 눌러도 확인(또는 Enter)을 눌러야 확정돼요. startDate: 값이 없을 때 달력이 보여 줄 날이에요.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: '업무', width: 150 },
{
id: 'due',
title: '마감일',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: '디자인 검수', due: '2026-03-05' },
{ id: 2, name: '문서 정리', due: null },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const watcher = new MutationObserver(() => current.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => {
off();
watcher.disconnect();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};버튼을 누르면 이 예제의 코드가 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.mode(api, $any($event.target).value)"
>
<option value="open" selected>바로 열기</option>
<option value="pick">선택기로만</option>
<option value="confirm">확인 단추</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;
name: string;
due: string | null;
}
// 예제 틀이 알려 주는 페이지 언어(ko/en)를 그리드 locale로 써요.
const pageLang = (): 'ko' | 'en' => (document.documentElement.dataset.lang === 'en' ? 'en' : 'ko');
// openOnEdit: 편집을 시작하면 선택기를 바로 열어요. pickOnly: 입력칸은 읽기 전용, 선택기로만 정해요.
// confirm: 날을 눌러도 확인(또는 Enter)을 눌러야 확정돼요. startDate: 값이 없을 때 달력이 보여 줄 날이에요.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: '업무', width: 150 },
{
id: 'due',
title: '마감일',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: '디자인 검수', due: '2026-03-05' },
{ id: 2, name: '문서 정리', due: null },
],
rowKey: 'id',
locale: pageLang(),
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
const watcher = new MutationObserver(() => current.setOptions({ locale: pageLang() }));
watcher.observe(document.documentElement, { attributes: true, attributeFilter: ['data-lang'] });
return () => {
off();
watcher.disconnect();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};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="Behavior" id="mode">
<option value="open" selected>Open at once</option>
<option value="pick">Picker only</option>
<option value="confirm">OK button</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('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));// openOnEdit: open the picker as soon as editing starts. pickOnly: the input is read-only, so the value is set only through the picker.
// confirm: clicking a day is not enough; the OK button (or Enter) must be pressed. startDate: the day the calendar shows when there is no value.
const columns = (mode) => [
{ id: 'name', title: 'Task', width: 150 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options = {
columns: columns('open'),
rows: [
{ id: 1, name: 'Design review', due: '2026-03-05' },
{ id: 2, name: 'Tidy documents', due: null },
],
rowKey: 'id',
locale: 'en',
};
export function setup(current, log) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
return () => {
off();
};
}
export const actions = {
edit: (current) => current.startEdit(1, 'due'),
mode: (current, value) => current.setColumns(columns(value ?? 'open')),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Choose how the date picker opens</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="edit">Edit first row</button>
<select aria-label="Behavior" id="mode">
<option value="open" selected>Open at once</option>
<option value="pick">Picker only</option>
<option value="confirm">OK button</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>
// openOnEdit: open the picker as soon as editing starts. pickOnly: the input is read-only, so the value is set only through the picker.
// confirm: clicking a day is not enough; the OK button (or Enter) must be pressed. startDate: the day the calendar shows when there is no value.
const columns = (mode) => [
{ id: 'name', title: 'Task', width: 150 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
const options = {
columns: columns('open'),
rows: [
{ id: 1, name: 'Design review', due: '2026-03-05' },
{ id: 2, name: 'Tidy documents', due: null },
],
rowKey: 'id',
locale: 'en',
};
function setup(current, log) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) => log(`row ${rowKey} · ${columnId} = ${String(newValue)}`));
return () => {
off();
};
}
const actions = {
edit: (current) => current.startEdit(1, 'due'),
mode: (current, value) => current.setColumns(columns(value ?? 'open')),
};
options.ariaLabel = "Choose how the date picker opens";
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('mode').addEventListener('change', (event) => actions.mode(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="Behavior"
disabled={!api}
onChange={(event) => api && actions.mode(api, event.target.value)}
>
<option value="open">Open at once</option>
<option value="pick">Picker only</option>
<option value="confirm">OK button</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
due: string | null;
}
// openOnEdit: open the picker as soon as editing starts. pickOnly: the input is read-only, so the value is set only through the picker.
// confirm: clicking a day is not enough; the OK button (or Enter) must be pressed. startDate: the day the calendar shows when there is no value.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: 'Task', width: 150 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: 'Design review', due: '2026-03-05' },
{ id: 2, name: 'Tidy documents', due: null },
],
rowKey: 'id',
locale: 'en',
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
return () => {
off();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};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="Behavior"
:disabled="!api"
@change="api && actions.mode(api, ($event.target as HTMLSelectElement).value)"
>
<option value="open" selected>Open at once</option>
<option value="pick">Picker only</option>
<option value="confirm">OK button</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;
name: string;
due: string | null;
}
// openOnEdit: open the picker as soon as editing starts. pickOnly: the input is read-only, so the value is set only through the picker.
// confirm: clicking a day is not enough; the OK button (or Enter) must be pressed. startDate: the day the calendar shows when there is no value.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: 'Task', width: 150 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: 'Design review', due: '2026-03-05' },
{ id: 2, name: 'Tidy documents', due: null },
],
rowKey: 'id',
locale: 'en',
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
return () => {
off();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};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="Behavior"
[disabled]="!api"
(change)="api && actions.mode(api, $any($event.target).value)"
>
<option value="open" selected>Open at once</option>
<option value="pick">Picker only</option>
<option value="confirm">OK button</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;
name: string;
due: string | null;
}
// openOnEdit: open the picker as soon as editing starts. pickOnly: the input is read-only, so the value is set only through the picker.
// confirm: clicking a day is not enough; the OK button (or Enter) must be pressed. startDate: the day the calendar shows when there is no value.
const columns = (mode: string): ColumnDef<Row>[] => [
{ id: 'name', title: 'Task', width: 150 },
{
id: 'due',
title: 'Due',
kind: 'date',
width: 170,
editable: true,
dateTime: {
startDate: '2030-07-01',
...(mode === 'open' ? { openOnEdit: true } : {}),
...(mode === 'pick' ? { pickOnly: true } : {}),
...(mode === 'confirm' ? { confirm: true } : {}),
},
},
];
export const options: GridOptions<Row> = {
columns: columns('open'),
rows: [
{ id: 1, name: 'Design review', due: '2026-03-05' },
{ id: 2, name: 'Tidy documents', due: null },
],
rowKey: 'id',
locale: 'en',
};
export function setup(current: GridApi<Row>, log: (message: string) => void) {
const off = current.on('editCommitted', ({ rowKey, columnId, newValue }) =>
log(`row ${rowKey} · ${columnId} = ${String(newValue)}`),
);
return () => {
off();
};
}
export const actions = {
edit: (current: GridApi<Row>) => current.startEdit(1, 'due'),
mode: (current: GridApi<Row>, value?: string) => current.setColumns(columns(value ?? 'open')),
};