본문으로 건너뛰기Skip to content
예제 첫화면Examples home

주 칸 편집: 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.

입문Beginner
직접 써 보기Live preview주 칸 편집: ISO 주 고르기Edit weeks: pick an ISO week

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<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>
main.js
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));
example.js
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 });
  },
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<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>
main.js
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));
example.js
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 });
  },
};