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

단계나 담당자에 따라 다른 아이콘 붙이기Different icons by level or owner

작업 이름 앞에 단계에 따라(묶음·폴더·문서) 또는 담당자에 따라 다른 아이콘을 붙여요. 펼침 화살표는 그대로 두고, 정렬과 검색은 아이콘 없이 원래 이름으로 해요.Put a different icon before each task name by level or by owner. The expand arrow stays as is, and sorting and filtering still use the plain name.

활용Intermediate
직접 써 보기Live preview단계나 담당자에 따라 다른 아이콘 붙이기Different icons by level or owner

코드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">
    <select aria-label="아이콘 기준" id="mode">
      <option value="depth" selected>단계별</option>
      <option value="owner">담당자별</option>
      <option value="none">붙이지 않기</option>
    </select>
  </div>
  <div id="grid" style="height: 430px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));
example.js
const rows = [
  {
    id: 'T1',
    parentId: null,
    task: '출시 준비',
    owner: '김서연',
    start: '2026-11-02',
    end: '2026-12-18',
  },
  {
    id: 'T10',
    parentId: 'T1',
    task: '기획',
    owner: '이준호',
    start: '2026-11-02',
    end: '2026-11-13',
  },
  {
    id: 'T11',
    parentId: 'T10',
    task: '요구사항 정리',
    owner: '이준호',
    start: '2026-11-02',
    end: '2026-11-06',
  },
  {
    id: 'T12',
    parentId: 'T10',
    task: '화면 설계',
    owner: '박민지',
    start: '2026-11-09',
    end: '2026-11-13',
  },
  {
    id: 'T20',
    parentId: 'T1',
    task: '개발',
    owner: '최도윤',
    start: '2026-11-16',
    end: '2026-12-04',
  },
  {
    id: 'T21',
    parentId: 'T20',
    task: '프런트엔드',
    owner: '정하은',
    start: '2026-11-16',
    end: '2026-11-27',
  },
  {
    id: 'T22',
    parentId: 'T20',
    task: '백엔드',
    owner: '최도윤',
    start: '2026-11-16',
    end: '2026-12-04',
  },
  {
    id: 'T30',
    parentId: 'T1',
    task: '테스트',
    owner: '박민지',
    start: '2026-12-07',
    end: '2026-12-18',
  },
  {
    id: 'T31',
    parentId: 'T30',
    task: '기능 테스트',
    owner: '박민지',
    start: '2026-12-07',
    end: '2026-12-11',
  },
  {
    id: 'T32',
    parentId: 'T30',
    task: '성능 테스트',
    owner: '임태민',
    start: '2026-12-14',
    end: '2026-12-18',
  },
  {
    id: 'T2',
    parentId: null,
    task: '운영 준비',
    owner: '김서연',
    start: '2026-12-07',
    end: '2026-12-23',
  },
  {
    id: 'T40',
    parentId: 'T2',
    task: '교육 자료 작성',
    owner: '한지우',
    start: '2026-12-07',
    end: '2026-12-11',
  },
];
const byId = new Map(rows.map((row) => [row.id, row]));
const depthOf = (row) => row.parentId === null ? 0 : depthOf(byId.get(row.parentId)) + 1;
let mode = 'depth';
// 펼침 화살표는 트리 전체가 같은 모양이에요(그림은 줄마다 못 바꿔요).
// 그래서 줄마다 다른 아이콘은 "이름 칸에 보여 줄 글자" 앞에 붙여요. 정렬·필터는 원래 이름으로 해요.
const byDepth = ['📦', '📁', '📄'];
const byOwner = { 김서연: '⭐', 이준호: '🔷', 박민지: '🟢', 최도윤: '🔶' };
const icon = (row) => mode === 'depth'
  ? byDepth[Math.min(depthOf(row), 2)]
  : mode === 'owner'
    ? (byOwner[row.owner] ?? '▫️')
    : '';
const columns = () => [
  {
    id: 'task',
    title: '작업',
    width: 240,
    formatValue: (value, row) => mode === 'none' ? String(value) : `${icon(row)} ${String(value)}`,
  },
  { id: 'owner', title: '담당자', width: 100 },
  { id: 'start', title: '시작', width: 110 },
  { id: 'end', title: '종료', width: 110 },
];
export const options = {
  columns: columns(),
  rows,
  rowKey: 'id',
  tree: { parentKey: 'parentId', column: 'task', expandDepth: 'all' },
};
export const actions = {
  mode: (api, value) => {
    mode = value === 'owner' || value === 'none' ? value : 'depth';
    api.setColumns(columns());
  },
};

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">
    <select aria-label="Icons by" id="mode">
      <option value="depth" selected>By level</option>
      <option value="owner">By owner</option>
      <option value="none">None</option>
    </select>
  </div>
  <div id="grid" style="height: 430px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));
example.js
const rows = [
  {
    id: 'T1',
    parentId: null,
    task: 'Release',
    owner: 'Emma Stone',
    start: '2026-11-02',
    end: '2026-12-18',
  },
  {
    id: 'T10',
    parentId: 'T1',
    task: 'Planning',
    owner: 'Liam Carter',
    start: '2026-11-02',
    end: '2026-11-13',
  },
  {
    id: 'T11',
    parentId: 'T10',
    task: 'Gather requirements',
    owner: 'Liam Carter',
    start: '2026-11-02',
    end: '2026-11-06',
  },
  {
    id: 'T12',
    parentId: 'T10',
    task: 'Screen design',
    owner: 'Mia Parker',
    start: '2026-11-09',
    end: '2026-11-13',
  },
  {
    id: 'T20',
    parentId: 'T1',
    task: 'Development',
    owner: 'Noah Davis',
    start: '2026-11-16',
    end: '2026-12-04',
  },
  {
    id: 'T21',
    parentId: 'T20',
    task: 'Frontend',
    owner: 'Ava Moore',
    start: '2026-11-16',
    end: '2026-11-27',
  },
  {
    id: 'T22',
    parentId: 'T20',
    task: 'Backend',
    owner: 'Noah Davis',
    start: '2026-11-16',
    end: '2026-12-04',
  },
  {
    id: 'T30',
    parentId: 'T1',
    task: 'Testing',
    owner: 'Mia Parker',
    start: '2026-12-07',
    end: '2026-12-18',
  },
  {
    id: 'T31',
    parentId: 'T30',
    task: 'Functional test',
    owner: 'Mia Parker',
    start: '2026-12-07',
    end: '2026-12-11',
  },
  {
    id: 'T32',
    parentId: 'T30',
    task: 'Performance test',
    owner: 'Ethan Lee',
    start: '2026-12-14',
    end: '2026-12-18',
  },
  {
    id: 'T2',
    parentId: null,
    task: 'Operations prep',
    owner: 'Emma Stone',
    start: '2026-12-07',
    end: '2026-12-23',
  },
  {
    id: 'T40',
    parentId: 'T2',
    task: 'Write training materials',
    owner: 'Grace Hall',
    start: '2026-12-07',
    end: '2026-12-11',
  },
];
const byId = new Map(rows.map((row) => [row.id, row]));
const depthOf = (row) => row.parentId === null ? 0 : depthOf(byId.get(row.parentId)) + 1;
let mode = 'depth';
// The expand arrow looks the same across the whole tree (the picture cannot differ per row).
// So a per-row icon goes in front of the text shown in the name cell. Sorting and filtering use the original name.
const byDepth = ['📦', '📁', '📄'];
const byOwner = {
  'Emma Stone': '⭐',
  'Liam Carter': '🔷',
  'Mia Parker': '🟢',
  'Noah Davis': '🔶',
};
const icon = (row) => mode === 'depth'
  ? byDepth[Math.min(depthOf(row), 2)]
  : mode === 'owner'
    ? (byOwner[row.owner] ?? '▫️')
    : '';
const columns = () => [
  {
    id: 'task',
    title: 'Task',
    width: 240,
    formatValue: (value, row) => mode === 'none' ? String(value) : `${icon(row)} ${String(value)}`,
  },
  { id: 'owner', title: 'Owner', width: 120 },
  { id: 'start', title: 'Start', width: 110 },
  { id: 'end', title: 'End', width: 110 },
];
export const options = {
  columns: columns(),
  rows,
  rowKey: 'id',
  tree: { parentKey: 'parentId', column: 'task', expandDepth: 'all' },
};
export const actions = {
  mode: (api, value) => {
    mode = value === 'owner' || value === 'none' ? value : 'depth';
    api.setColumns(columns());
  },
};