주 칸 편집: ISO 주 고르기Edit weeks: pick an ISO week
kind: 'week' 컬럼은 날 격자의 줄 하나가 한 주예요. 값은 YYYY-Www 글자이고, 월요일에 시작해요. min·max 밖의 주는 줄 전체가 선택 불가예요.In a kind: 'week' column one row of the day grid is one week. The value is a YYYY-Www string and weeks start on Monday. Weeks outside min and max are disabled as a whole row.
코드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="openWeek">스프린트 주 편집</button>
<button type="button" id="badWeek">범위 밖 값 넣기</button>
</div>
<div id="grid" style="height: 300px"></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('openWeek').addEventListener('click', () => actions.openWeek(api));
document.getElementById('badWeek').addEventListener('click', () => actions.badWeek(api));const en = document.documentElement.dataset.lang === 'en';
const rows = [
{ id: 1, task: en ? 'Improve login' : '로그인 개선', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: en ? 'Check export' : '내보내기 점검', sprint: '2026-W46', due: null },
{ id: 3, task: en ? 'Year-end closing' : '연말 정산', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week'는 ISO 주(월요일 시작)를 골라요. 값은 시간대가 없는 글자 YYYY-Www이고, 날 격자의 줄 하나가 한 주예요.
export const options = {
columns: [
{ id: 'task', title: en ? 'Task' : '작업', width: 150 },
{
id: 'sprint',
title: en ? 'Sprint week' : '스프린트 주',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: en ? 'Due week' : '마감 주', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: en ? 'Edit weeks' : '주 편집',
};
export function setup(api, log) {
log({
ko: '스프린트 주 칸을 더블클릭하세요. 줄을 누르거나 방향키(±1주), PageUp/Down(±1달), Home/End(그 해 첫·마지막 주)로 옮겨요. 2026-W12처럼 써도 돼요.',
en: 'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
});
const offs = [
api.on('editCommitted', (e) => log({
ko: `${e.rowKey}번 ${e.columnId} → ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${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 = {
openWeek: (api) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025년에는 53주가 없고 min(2026-W10) 앞의 주도 막혀요.
badWeek: (api) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>주 칸 편집: ISO 주 고르기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="openWeek">스프린트 주 편집</button>
<button type="button" id="badWeek">범위 밖 값 넣기</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const en = document.documentElement.dataset.lang === 'en';
const rows = [
{ id: 1, task: en ? 'Improve login' : '로그인 개선', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: en ? 'Check export' : '내보내기 점검', sprint: '2026-W46', due: null },
{ id: 3, task: en ? 'Year-end closing' : '연말 정산', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week'는 ISO 주(월요일 시작)를 골라요. 값은 시간대가 없는 글자 YYYY-Www이고, 날 격자의 줄 하나가 한 주예요.
const options = {
columns: [
{ id: 'task', title: en ? 'Task' : '작업', width: 150 },
{
id: 'sprint',
title: en ? 'Sprint week' : '스프린트 주',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: en ? 'Due week' : '마감 주', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: en ? 'Edit weeks' : '주 편집',
};
function setup(api, log) {
log({
ko: '스프린트 주 칸을 더블클릭하세요. 줄을 누르거나 방향키(±1주), PageUp/Down(±1달), Home/End(그 해 첫·마지막 주)로 옮겨요. 2026-W12처럼 써도 돼요.',
en: 'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
});
const offs = [
api.on('editCommitted', (e) => log({
ko: `${e.rowKey}번 ${e.columnId} → ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${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 = {
openWeek: (api) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025년에는 53주가 없고 min(2026-W10) 앞의 주도 막혀요.
badWeek: (api) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};
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('openWeek').addEventListener('click', () => actions.openWeek(api));
document.getElementById('badWeek').addEventListener('click', () => actions.badWeek(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.openWeek(api)}
>스프린트 주 편집</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.badWeek(api)}
>범위 밖 값 넣기</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: en ? 'Improve login' : '로그인 개선', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: en ? 'Check export' : '내보내기 점검', sprint: '2026-W46', due: null },
{ id: 3, task: en ? 'Year-end closing' : '연말 정산', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week'는 ISO 주(월요일 시작)를 골라요. 값은 시간대가 없는 글자 YYYY-Www이고, 날 격자의 줄 하나가 한 주예요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: en ? 'Task' : '작업', width: 150 },
{
id: 'sprint',
title: en ? 'Sprint week' : '스프린트 주',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: en ? 'Due week' : '마감 주', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: en ? 'Edit weeks' : '주 편집',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '스프린트 주 칸을 더블클릭하세요. 줄을 누르거나 방향키(±1주), PageUp/Down(±1달), Home/End(그 해 첫·마지막 주)로 옮겨요. 2026-W12처럼 써도 돼요.',
en: 'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
});
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 ${e.columnId} → ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${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 = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025년에는 53주가 없고 min(2026-W10) 앞의 주도 막혀요.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};버튼을 누르면 이 예제의 코드가 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.openWeek(api)"
>스프린트 주 편집</button>
<button type="button" :disabled="!api" @click="api && actions.badWeek(api)">범위 밖 값 넣기</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: en ? 'Improve login' : '로그인 개선', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: en ? 'Check export' : '내보내기 점검', sprint: '2026-W46', due: null },
{ id: 3, task: en ? 'Year-end closing' : '연말 정산', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week'는 ISO 주(월요일 시작)를 골라요. 값은 시간대가 없는 글자 YYYY-Www이고, 날 격자의 줄 하나가 한 주예요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: en ? 'Task' : '작업', width: 150 },
{
id: 'sprint',
title: en ? 'Sprint week' : '스프린트 주',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: en ? 'Due week' : '마감 주', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: en ? 'Edit weeks' : '주 편집',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '스프린트 주 칸을 더블클릭하세요. 줄을 누르거나 방향키(±1주), PageUp/Down(±1달), Home/End(그 해 첫·마지막 주)로 옮겨요. 2026-W12처럼 써도 돼요.',
en: 'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
});
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 ${e.columnId} → ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${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 = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025년에는 53주가 없고 min(2026-W10) 앞의 주도 막혀요.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};버튼을 누르면 이 예제의 코드가 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.openWeek(api)"
>스프린트 주 편집</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.badWeek(api)"
>범위 밖 값 넣기</button>
</div>
<mx-grid style="height: 300px" [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';
const en = document.documentElement.dataset.lang === 'en';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: en ? 'Improve login' : '로그인 개선', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: en ? 'Check export' : '내보내기 점검', sprint: '2026-W46', due: null },
{ id: 3, task: en ? 'Year-end closing' : '연말 정산', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week'는 ISO 주(월요일 시작)를 골라요. 값은 시간대가 없는 글자 YYYY-Www이고, 날 격자의 줄 하나가 한 주예요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: en ? 'Task' : '작업', width: 150 },
{
id: 'sprint',
title: en ? 'Sprint week' : '스프린트 주',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: en ? 'Due week' : '마감 주', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: en ? 'Edit weeks' : '주 편집',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '스프린트 주 칸을 더블클릭하세요. 줄을 누르거나 방향키(±1주), PageUp/Down(±1달), Home/End(그 해 첫·마지막 주)로 옮겨요. 2026-W12처럼 써도 돼요.',
en: 'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
});
const offs = [
api.on('editCommitted', (e) =>
log({
ko: `${e.rowKey}번 ${e.columnId} → ${String(e.newValue)}`,
en: `Row ${e.rowKey} ${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 = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025년에는 53주가 없고 min(2026-W10) 앞의 주도 막혀요.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};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="openWeek">Edit sprint week</button>
<button type="button" id="badWeek">Set an out-of-range value</button>
</div>
<div id="grid" style="height: 300px"></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('openWeek').addEventListener('click', () => actions.openWeek(api));
document.getElementById('badWeek').addEventListener('click', () => actions.badWeek(api));const rows = [
{ id: 1, task: 'Improve login', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: 'Check export', sprint: '2026-W46', due: null },
{ id: 3, task: 'Year-end closing', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week' picks an ISO week (starting on Monday). The value is a time-zone-free string YYYY-Www, and one row of the day grid is one week.
export const options = {
columns: [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'sprint',
title: 'Sprint week',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: 'Due week', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: 'Edit weeks',
};
export function setup(api, log) {
log('Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.');
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${e.columnId} → ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openWeek: (api) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025 has no week 53, and weeks before min (2026-W10) are blocked too.
badWeek: (api) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Edit weeks: pick an ISO week</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="openWeek">Edit sprint week</button>
<button type="button" id="badWeek">Set an out-of-range value</button>
</div>
<div id="grid" style="height: 300px"></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: 'Improve login', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: 'Check export', sprint: '2026-W46', due: null },
{ id: 3, task: 'Year-end closing', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week' picks an ISO week (starting on Monday). The value is a time-zone-free string YYYY-Www, and one row of the day grid is one week.
const options = {
columns: [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'sprint',
title: 'Sprint week',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: 'Due week', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: 'Edit weeks',
};
function setup(api, log) {
log('Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.');
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${e.columnId} → ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
const actions = {
openWeek: (api) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025 has no week 53, and weeks before min (2026-W10) are blocked too.
badWeek: (api) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};
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('openWeek').addEventListener('click', () => actions.openWeek(api));
document.getElementById('badWeek').addEventListener('click', () => actions.badWeek(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.openWeek(api)}
>Edit sprint week</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.badWeek(api)}
>Set an out-of-range value</button>
</div>
<Grid style={{ height: 300 }} 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;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: 'Improve login', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: 'Check export', sprint: '2026-W46', due: null },
{ id: 3, task: 'Year-end closing', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week' picks an ISO week (starting on Monday). The value is a time-zone-free string YYYY-Www, and one row of the day grid is one week.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'sprint',
title: 'Sprint week',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: 'Due week', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: 'Edit weeks',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
);
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${e.columnId} → ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025 has no week 53, and weeks before min (2026-W10) are blocked too.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};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.openWeek(api)"
>Edit sprint week</button>
<button type="button" :disabled="!api" @click="api && actions.badWeek(api)">Set an out-of-range value</button>
</div>
<Grid style="height: 300px" :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;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: 'Improve login', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: 'Check export', sprint: '2026-W46', due: null },
{ id: 3, task: 'Year-end closing', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week' picks an ISO week (starting on Monday). The value is a time-zone-free string YYYY-Www, and one row of the day grid is one week.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'sprint',
title: 'Sprint week',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: 'Due week', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: 'Edit weeks',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
);
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${e.columnId} → ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025 has no week 53, and weeks before min (2026-W10) are blocked too.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};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.openWeek(api)"
>Edit sprint week</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.badWeek(api)"
>Set an out-of-range value</button>
</div>
<mx-grid style="height: 300px" [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;
sprint: string;
due: string | null;
}
const rows: Row[] = [
{ id: 1, task: 'Improve login', sprint: '2026-W45', due: '2026-W47' },
{ id: 2, task: 'Check export', sprint: '2026-W46', due: null },
{ id: 3, task: 'Year-end closing', sprint: '2026-W52', due: '2026-W53' },
];
// kind: 'week' picks an ISO week (starting on Monday). The value is a time-zone-free string YYYY-Www, and one row of the day grid is one week.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'sprint',
title: 'Sprint week',
kind: 'week',
width: 150,
editable: true,
dateTime: { min: '2026-W10', max: '2026-W53' },
},
{ id: 'due', title: 'Due week', kind: 'week', width: 150, editable: true },
],
rows,
rowKey: 'id',
ariaLabel: 'Edit weeks',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Double-click a sprint week. Click a row or use the arrows (±1 week), PageUp/Down (±1 month) and Home/End (first and last week of the year). You can also type 2026-W12.',
);
const offs = [
api.on('editCommitted', (e) => log(`Row ${e.rowKey} ${e.columnId} → ${String(e.newValue)}`)),
api.on('validationFailed', (e) => log(`Could not confirm: ${e.message}`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
openWeek: (api: GridApi<Row>) => {
api.startEdit(1, 'sprint', { open: true });
},
// 2025 has no week 53, and weeks before min (2026-W10) are blocked too.
badWeek: (api: GridApi<Row>) => {
api.setCellValue(2, 'sprint', '2026-W05', { validate: true });
},
};