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

프로젝트 관리 화면 만들기Building a project-management screen

작업 트리 표, 간트 차트, 구분선, 선택한 작업의 상세 줄을 한 화면에 모아 만들어요.Put a task-tree grid, a Gantt chart, a splitter and a detail line for the selected task on one screen.

활용Intermediate
직접 써 보기Live preview프로젝트 관리 화면 만들기Building a project-management screen

코드Code

탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.

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

이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/gantt @maxgrid/gantt-core로 설치하세요.

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

index.html
<div id="app">
  <div class="toolbar">
    <select aria-label="눈금 단위" id="zoom">
      <option value="day">일</option>
      <option value="week" selected>주</option>
      <option value="month">월</option>
    </select>
    <input
      type="text"
      aria-label="작업 찾기"
      placeholder="작업 이름이나 담당자"
      id="search"
    />
    <button type="button" id="next">다음 찾기</button>
  </div>
  <div id="grid" style="height: 520px"></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('zoom').addEventListener('change', (event) => actions.zoom(api, event.target.value));
document.getElementById('search').addEventListener('input', (event) => actions.search(api, event.target.value));
document.getElementById('next').addEventListener('click', () => actions.next(api));
example.js
import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture, normalizePmsData, toPmsShape } from '@maxgrid/gantt-core';
// 1) "서버": 잠깐 기다린 뒤 프로젝트를 snake_case JSON으로 돌려줘요. 실제 앱에서는 여기서 fetch()를 불러요.
//    데이터는 만들어 낸 것(작업 약 300개)이라 따로 받거나 설치할 것이 없어요.
const serverJson = toPmsShape(makeFixture({ tasks: 300, dependencies: 360, seed: 7, startDate: '2026-10-05' }));
function fetchProject() {
  return new Promise((resolve) => {
    setTimeout(() => resolve(structuredClone(serverJson)), 250);
  });
}
// 2) 호스트는 작업 목록을 하나만 가져요. 표 행과 차트 데이터가 모두 여기서 나오므로 서로 어긋나지 않아요.
const toRow = (t) => ({
  id: t.id,
  parentId: t.parentId,
  wbs: t.wbsCode ?? '',
  name: t.name,
  assignee: t.assigneeName ?? '',
  start: t.plannedStart ?? '',
  end: t.plannedEnd ?? '',
  progress: t.progressPct,
});
export const options = {
  columns: [
    { id: 'wbs', title: 'WBS', width: 64 },
    { id: 'name', title: '작업', width: 200 },
    { id: 'assignee', title: '담당자', width: 100 },
    { id: 'start', title: '시작', width: 96 },
    { id: 'end', title: '종료', width: 96 },
    { id: 'progress', title: '진행률(%)', kind: 'number', width: 84, align: 'end' },
  ],
  rows: [],
  rowKey: 'id',
  // 표의 행·머리글 높이는 차트와 같아야 줄이 맞아요.
  rowHeight: 32,
  headerHeight: 48,
  verticalScroll: 'external',
  selection: 'single',
  tree: { parentKey: 'parentId', column: 'name', expandDepth: 1 },
  ariaLabel: '프로젝트 작업',
};
// 3) 배치: [표 | 구분선 | 차트] 아래에 선택한 작업의 상세 한 줄.
function mount(api) {
  const gridEl = api.getGridElement();
  const host = gridEl.parentElement;
  const box = document.createElement('div');
  const stage = document.createElement('div');
  const left = document.createElement('div');
  const right = document.createElement('div');
  const strip = document.createElement('div');
  const finder = document.createElement('div');
  box.style.cssText = 'display: flex; flex-direction: column; width: 100%; height: 100%;';
  stage.style.cssText = 'position: relative; flex: 1; min-height: 0;';
  strip.style.cssText =
    'flex: none; padding: 10px 12px; font: 13px/1.4 system-ui, sans-serif; border-top: 1px solid var(--mxg-border, #d0d5dd); min-height: 20px;';
  strip.setAttribute('role', 'status');
  finder.setAttribute('role', 'status');
  finder.style.cssText =
    'flex: none; padding: 6px 12px; font: 13px/1.4 system-ui, sans-serif; border-top: 1px solid var(--mxg-border, #d0d5dd); min-height: 18px; color: var(--mxg-text-muted, #475467);';
  stage.append(left, right);
  box.append(stage, finder, strip);
  host.append(box);
  left.append(gridEl);
  const split = createSplitView({
    left,
    right,
    container: stage,
    initial: 0.45,
    min: box.clientWidth < 600 ? 110 : 240,
  });
  const gantt = createGantt(right, {
    rowHeight: 32,
    locale: 'ko',
    verticalScroll: 'external',
    zoom: 'week',
  });
  return {
    gantt,
    strip,
    finder,
    destroy() {
      gantt.destroy();
      split.destroy();
      host.append(gridEl);
      box.remove();
    },
  };
}
let view = null;
let tasks = new Map();
function describe(id) {
  const t = id === null ? undefined : tasks.get(id);
  if (!t)
    return '작업을 고르면 여기에 상세가 나와요.';
  const dates = t.plannedStart ? `${t.plannedStart} ~ ${t.plannedEnd}` : '일정 없음';
  return `${t.wbsCode} ${t.name} · ${t.assigneeName ?? '담당자 없음'} · ${dates} · ${t.progressPct}%`;
}
let hits = [];
let hitAt = 0;
function showHit(api, at) {
  const v = view;
  const t = hits[at];
  if (!v || !t)
    return;
  hitAt = at;
  // Open the parents so the row is visible, then select it and bring the grid and the chart to it.
  for (let p = t.parentId; p; p = tasks.get(p)?.parentId ?? null)
    api.expandRow(p);
  api.setSelectedKeys([t.id]);
  api.scrollToRow(t.id);
  v.gantt.selectRow(t.id);
  v.gantt.scrollToRow(t.id);
  v.strip.textContent = describe(t.id);
}
// 찾기: 칸 표시(api.find)에 더해, 맞는 작업 수를 알리고 첫 작업을 고르고 표와 차트를 그 행으로 옮겨요. 비우면 처음 상태로 돌아가요.
function runFind(api, text) {
  api.find(text);
  const v = view;
  if (!v)
    return;
  const q = text.toLowerCase();
  hits = q
    ? [...tasks.values()].filter((t) => t.name.toLowerCase().includes(q) || (t.assigneeName ?? '').toLowerCase().includes(q))
    : [];
  v.finder.textContent = q
    ? hits.length
      ? `"${text}"에 맞는 작업이 ${hits.length}개예요`
      : `"${text}"에 맞는 작업이 없어요`
    : '';
  if (hits.length)
    showHit(api, 0);
  else if (!q) {
    api.setSelectedKeys([]);
    v.gantt.selectRow(null);
    v.strip.textContent = describe(null);
  }
}
export function setup(api, log) {
  const mounted = mount(api);
  view = mounted;
  mounted.strip.textContent = '서버에서 프로젝트를 불러오는 중이에요...';
  let gone = false;
  // 4) 불러오기: 서버 JSON -> 변환기 -> GanttData 하나 -> 표 행 + 차트 데이터.
  void fetchProject().then((json) => {
    if (gone)
      return;
    const data = normalizePmsData(json);
    tasks = new Map(data.tasks.map((t) => [t.id, t]));
    api.setRows(data.tasks.map(toRow));
    mounted.gantt.setData(data);
    mounted.strip.textContent = describe(null);
    log({
      ko: `작업 ${data.tasks.length}개, 의존 ${data.dependencies.length}개를 불러왔어요`,
      en: `Loaded ${data.tasks.length} tasks and ${data.dependencies.length} dependencies`,
    });
  });
  // 5) 표와 차트의 스크롤·선택·접기를 묶고, 선택한 작업을 보여 줘요.
  const unlink = mounted.gantt.attachGrid(api);
  const off = mounted.gantt.on('row-select', (e) => {
    mounted.strip.textContent = describe(e.taskId);
  });
  return () => {
    gone = true;
    off();
    unlink();
    mounted.destroy();
    view = null;
  };
}
export const actions = {
  zoom: (_api, value) => {
    view?.gantt.setZoom(value === 'day' || value === 'month' ? value : 'week');
  },
  search: (api, value) => runFind(api, (value ?? '').trim()),
  // 다음 찾기: 다음 일치 작업으로 옮겨요.
  next: (api) => {
    api.findNext();
    if (hits.length)
      showHit(api, (hitAt + 1) % hits.length);
  },
};

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

This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/gantt @maxgrid/gantt-core.

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">
    <select aria-label="Scale" id="zoom">
      <option value="day">Day</option>
      <option value="week" selected>Week</option>
      <option value="month">Month</option>
    </select>
    <input
      type="text"
      aria-label="Find a task"
      placeholder="Task name or assignee"
      id="search"
    />
    <button type="button" id="next">Next match</button>
  </div>
  <div id="grid" style="height: 520px"></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('zoom').addEventListener('change', (event) => actions.zoom(api, event.target.value));
document.getElementById('search').addEventListener('input', (event) => actions.search(api, event.target.value));
document.getElementById('next').addEventListener('click', () => actions.next(api));
example.js
import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture, normalizePmsData, toPmsShape } from '@maxgrid/gantt-core';
// 1) The "server": answers with the project as snake_case JSON after a short delay. A real app calls fetch() here.
//    The data is generated (about 300 tasks), so there is nothing to download or install.
const serverJson = toPmsShape(makeFixture({ tasks: 300, dependencies: 360, seed: 7, startDate: '2026-10-05' }));
function fetchProject() {
  return new Promise((resolve) => {
    setTimeout(() => resolve(structuredClone(serverJson)), 250);
  });
}
// 2) The host keeps one list of tasks. The grid rows and the chart data both come from it, so they never disagree.
const toRow = (t) => ({
  id: t.id,
  parentId: t.parentId,
  wbs: t.wbsCode ?? '',
  name: t.name,
  assignee: t.assigneeName ?? '',
  start: t.plannedStart ?? '',
  end: t.plannedEnd ?? '',
  progress: t.progressPct,
});
export const options = {
  columns: [
    { id: 'wbs', title: 'WBS', width: 64 },
    { id: 'name', title: 'Task', width: 200 },
    { id: 'assignee', title: 'Assignee', width: 100 },
    { id: 'start', title: 'Start', width: 96 },
    { id: 'end', title: 'End', width: 96 },
    { id: 'progress', title: 'Progress (%)', kind: 'number', width: 84, align: 'end' },
  ],
  rows: [],
  rowKey: 'id',
  // Row and header heights must match the chart so the lines line up.
  rowHeight: 32,
  headerHeight: 48,
  verticalScroll: 'external',
  selection: 'single',
  tree: { parentKey: 'parentId', column: 'name', expandDepth: 1 },
  ariaLabel: 'Project tasks',
};
// 3) Layout: [grid | splitter | chart] above a one-line detail strip for the selected task.
function mount(api) {
  const gridEl = api.getGridElement();
  const host = gridEl.parentElement;
  const box = document.createElement('div');
  const stage = document.createElement('div');
  const left = document.createElement('div');
  const right = document.createElement('div');
  const strip = document.createElement('div');
  const finder = document.createElement('div');
  box.style.cssText = 'display: flex; flex-direction: column; width: 100%; height: 100%;';
  stage.style.cssText = 'position: relative; flex: 1; min-height: 0;';
  strip.style.cssText =
    'flex: none; padding: 10px 12px; font: 13px/1.4 system-ui, sans-serif; border-top: 1px solid var(--mxg-border, #d0d5dd); min-height: 20px;';
  strip.setAttribute('role', 'status');
  finder.setAttribute('role', 'status');
  finder.style.cssText =
    'flex: none; padding: 6px 12px; font: 13px/1.4 system-ui, sans-serif; border-top: 1px solid var(--mxg-border, #d0d5dd); min-height: 18px; color: var(--mxg-text-muted, #475467);';
  stage.append(left, right);
  box.append(stage, finder, strip);
  host.append(box);
  left.append(gridEl);
  const split = createSplitView({
    left,
    right,
    container: stage,
    initial: 0.45,
    min: box.clientWidth < 600 ? 110 : 240,
  });
  const gantt = createGantt(right, {
    rowHeight: 32,
    locale: 'en',
    verticalScroll: 'external',
    zoom: 'week',
  });
  return {
    gantt,
    strip,
    finder,
    destroy() {
      gantt.destroy();
      split.destroy();
      host.append(gridEl);
      box.remove();
    },
  };
}
let view = null;
let tasks = new Map();
function describe(id) {
  const t = id === null ? undefined : tasks.get(id);
  if (!t)
    return 'Select a task to see its details here.';
  const dates = t.plannedStart ? `${t.plannedStart} to ${t.plannedEnd}` : 'not scheduled';
  return `${t.wbsCode} ${t.name} · ${t.assigneeName ?? 'unassigned'} · ${dates} · ${t.progressPct}%`;
}
let hits = [];
let hitAt = 0;
function showHit(api, at) {
  const v = view;
  const t = hits[at];
  if (!v || !t)
    return;
  hitAt = at;
  // Open the parents so the row is visible, then select it and bring the grid and the chart to it.
  for (let p = t.parentId; p; p = tasks.get(p)?.parentId ?? null)
    api.expandRow(p);
  api.setSelectedKeys([t.id]);
  api.scrollToRow(t.id);
  v.gantt.selectRow(t.id);
  v.gantt.scrollToRow(t.id);
  v.strip.textContent = describe(t.id);
}
// Find: besides marking cells (api.find), report how many tasks match, select the first one and move the grid and the chart to its row. Clearing the box restores the start state.
function runFind(api, text) {
  api.find(text);
  const v = view;
  if (!v)
    return;
  const q = text.toLowerCase();
  hits = q
    ? [...tasks.values()].filter((t) => t.name.toLowerCase().includes(q) || (t.assigneeName ?? '').toLowerCase().includes(q))
    : [];
  v.finder.textContent = q
    ? hits.length
      ? `${hits.length} tasks match "${text}"`
      : `No task matches "${text}"`
    : '';
  if (hits.length)
    showHit(api, 0);
  else if (!q) {
    api.setSelectedKeys([]);
    v.gantt.selectRow(null);
    v.strip.textContent = describe(null);
  }
}
export function setup(api, log) {
  const mounted = mount(api);
  view = mounted;
  mounted.strip.textContent = 'Loading the project from the server...';
  let gone = false;
  // 4) Load: server JSON -> normalizer -> one GanttData -> grid rows + chart data.
  void fetchProject().then((json) => {
    if (gone)
      return;
    const data = normalizePmsData(json);
    tasks = new Map(data.tasks.map((t) => [t.id, t]));
    api.setRows(data.tasks.map(toRow));
    mounted.gantt.setData(data);
    mounted.strip.textContent = describe(null);
    log(`Loaded ${data.tasks.length} tasks and ${data.dependencies.length} dependencies`);
  });
  // 5) Link scroll, selection and collapse of grid and chart, and show the selected task.
  const unlink = mounted.gantt.attachGrid(api);
  const off = mounted.gantt.on('row-select', (e) => {
    mounted.strip.textContent = describe(e.taskId);
  });
  return () => {
    gone = true;
    off();
    unlink();
    mounted.destroy();
    view = null;
  };
}
export const actions = {
  zoom: (_api, value) => {
    view?.gantt.setZoom(value === 'day' || value === 'month' ? value : 'week');
  },
  search: (api, value) => runFind(api, (value ?? '').trim()),
  // Next match: move to the next matching task.
  next: (api) => {
    api.findNext();
    if (hits.length)
      showHit(api, (hitAt + 1) % hits.length);
  },
};