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

트리를 펼칠 때의 움직임Motion when a tree opens

motion: true면 트리 화살표가 돌고, 펼치거나 접을 때 아래 줄들이 제자리로 미끄러져요. 기본은 꺼져 있어요.With motion: true the tree arrow turns and the rows below slide into place when a branch opens or closes. It is off by default.

입문Beginner
직접 써 보기Live preview트리를 펼칠 때의 움직임Motion when a tree opens

코드Code

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

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

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

index.html
<div id="app">
  <div class="toolbar">
    <button type="button" id="expandAll">모두 열기</button>
    <button type="button" id="collapseAll">모두 닫기</button>
    <button type="button" id="motion">움직임 켜기·끄기</button>
  </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('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(api));
document.getElementById('motion').addEventListener('click', () => actions.motion(api));
example.js
// 번호(code)가 첫 컬럼이고, 펼침 화살표는 두 번째 컬럼인 "작업"에 붙어요.
const rows = [
  { id: 'T1', parentId: null, code: 'T1', task: '출시 준비', owner: '김서연', end: '2026-12-18' },
  { id: 'T10', parentId: 'T1', code: 'T10', task: '기획', owner: '이준호', end: '2026-11-13' },
  {
    id: 'T11',
    parentId: 'T10',
    code: 'T11',
    task: '요구사항 정리',
    owner: '이준호',
    end: '2026-11-06',
  },
  {
    id: 'T12',
    parentId: 'T10',
    code: 'T12',
    task: '화면 설계',
    owner: '박민지',
    end: '2026-11-13',
  },
  { id: 'T20', parentId: 'T1', code: 'T20', task: '개발', owner: '최도윤', end: '2026-12-04' },
  {
    id: 'T21',
    parentId: 'T20',
    code: 'T21',
    task: '프런트엔드',
    owner: '정하은',
    end: '2026-11-27',
  },
  { id: 'T22', parentId: 'T20', code: 'T22', task: '백엔드', owner: '최도윤', end: '2026-12-04' },
  { id: 'T30', parentId: 'T1', code: 'T30', task: '테스트', owner: '박민지', end: '2026-12-18' },
  {
    id: 'T31',
    parentId: 'T30',
    code: 'T31',
    task: '기능 테스트',
    owner: '박민지',
    end: '2026-12-11',
  },
  {
    id: 'T32',
    parentId: 'T30',
    code: 'T32',
    task: '성능 테스트',
    owner: '임태민',
    end: '2026-12-18',
  },
  { id: 'T2', parentId: null, code: 'T2', task: '운영 준비', owner: '김서연', end: '2026-12-23' },
  {
    id: 'T40',
    parentId: 'T2',
    code: 'T40',
    task: '교육 자료 작성',
    owner: '한지우',
    end: '2026-12-11',
  },
];
export const options = {
  columns: [
    { id: 'code', title: '번호', width: 90 },
    { id: 'task', title: '작업', width: 220 },
    { id: 'owner', title: '담당자', width: 100 },
    { id: 'end', title: '종료', width: 110 },
  ],
  rows,
  rowKey: 'id',
  tree: { parentKey: 'parentId', column: 'task', expandDepth: 1 },
  // motion: true면 펼침 화살표가 돌고 아래 줄들이 부드럽게 내려가요(기본은 꺼짐).
  motion: true,
};
export const actions = {
  expandAll: (api) => api.expandAll(),
  collapseAll: (api) => api.collapseAll(),
  motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};

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="expandAll">Expand all</button>
    <button type="button" id="collapseAll">Collapse all</button>
    <button type="button" id="motion">Motion on/off</button>
  </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('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(api));
document.getElementById('motion').addEventListener('click', () => actions.motion(api));
example.js
// The code is the first column, and the expand arrow sits on the second column, "Task".
const rows = [
  { id: 'T1', parentId: null, code: 'T1', task: 'Release', owner: 'Emma Stone', end: '2026-12-18' },
  {
    id: 'T10',
    parentId: 'T1',
    code: 'T10',
    task: 'Planning',
    owner: 'Liam Carter',
    end: '2026-11-13',
  },
  {
    id: 'T11',
    parentId: 'T10',
    code: 'T11',
    task: 'Gather requirements',
    owner: 'Liam Carter',
    end: '2026-11-06',
  },
  {
    id: 'T12',
    parentId: 'T10',
    code: 'T12',
    task: 'Screen design',
    owner: 'Mia Parker',
    end: '2026-11-13',
  },
  {
    id: 'T20',
    parentId: 'T1',
    code: 'T20',
    task: 'Development',
    owner: 'Noah Davis',
    end: '2026-12-04',
  },
  {
    id: 'T21',
    parentId: 'T20',
    code: 'T21',
    task: 'Frontend',
    owner: 'Ava Moore',
    end: '2026-11-27',
  },
  {
    id: 'T22',
    parentId: 'T20',
    code: 'T22',
    task: 'Backend',
    owner: 'Noah Davis',
    end: '2026-12-04',
  },
  {
    id: 'T30',
    parentId: 'T1',
    code: 'T30',
    task: 'Testing',
    owner: 'Mia Parker',
    end: '2026-12-18',
  },
  {
    id: 'T31',
    parentId: 'T30',
    code: 'T31',
    task: 'Functional test',
    owner: 'Mia Parker',
    end: '2026-12-11',
  },
  {
    id: 'T32',
    parentId: 'T30',
    code: 'T32',
    task: 'Performance test',
    owner: 'Ethan Lee',
    end: '2026-12-18',
  },
  {
    id: 'T2',
    parentId: null,
    code: 'T2',
    task: 'Operations prep',
    owner: 'Emma Stone',
    end: '2026-12-23',
  },
  {
    id: 'T40',
    parentId: 'T2',
    code: 'T40',
    task: 'Write training materials',
    owner: 'Grace Hall',
    end: '2026-12-11',
  },
];
export const options = {
  columns: [
    { id: 'code', title: 'Code', width: 90 },
    { id: 'task', title: 'Task', width: 220 },
    { id: 'owner', title: 'Owner', width: 120 },
    { id: 'end', title: 'End', width: 110 },
  ],
  rows,
  rowKey: 'id',
  tree: { parentKey: 'parentId', column: 'task', expandDepth: 1 },
  // With motion: true the expand arrow turns and the rows below slide down smoothly (off by default).
  motion: true,
};
export const actions = {
  expandAll: (api) => api.expandAll(),
  collapseAll: (api) => api.collapseAll(),
  motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};