시작할 때 열어 둘 가지 정하기Choose which branches start open
처음에는 모두 닫아 두고, 원하는 가지만 열린 상태로 시작할 수 있어요. 열어 둔 줄을 선택까지 해 두면 어디를 보라는 건지 바로 알아봐요.Start closed, then open only the branches you want and select a row so people see where to look.
코드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="reopen">처음 상태로</button>
<button type="button" id="reveal">깊은 줄로 가기</button>
<button type="button" id="expandAll">모두 열기</button>
<button type="button" id="collapseAll">모두 닫기</button>
</div>
<div id="grid" style="height: 330px"></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('reopen').addEventListener('click', () => actions.reopen(api));
document.getElementById('reveal').addEventListener('click', () => actions.reveal(api));
document.getElementById('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(api));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: 'T211',
parentId: 'T21',
task: '로그인 화면',
owner: '정하은',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: '목록 화면',
owner: '강지후',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: '백엔드',
owner: '최도윤',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API 설계',
owner: '최도윤',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: '데이터베이스 구성',
owner: '윤서아',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: '배포 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: '서버 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options = {
columns: [
{ id: 'task', title: '작업', width: 220 },
{ id: 'owner', title: '담당자', width: 100 },
{ id: 'start', title: '시작', width: 110 },
{ id: 'end', title: '종료', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // 처음에는 모두 닫아 두고
};
let say = () => { };
// 시작할 때 열어 둘 가지와 눌러 둘 줄을 정해요. "출시 준비 > 개발 > 백엔드"가 열리고 백엔드가 선택돼요.
function openInitial(api) {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22'])
api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api, log) {
say = log;
openInitial(api);
log({
ko: '"출시 준비 > 개발 > 백엔드"가 열린 채로 시작했고, 백엔드가 선택돼 있어요.',
en: 'Started with "출시 준비 > 개발 > 백엔드" open and Backend (백엔드) selected.',
});
}
export const actions = {
reopen: (api) => {
openInitial(api);
say({ ko: '처음 상태로 되돌렸어요.', en: 'Back to the starting state.' });
},
// 깊이 숨어 있는 줄로 가려면 그 줄의 조상을 모두 열어야 해요. revealRow가 알아서 열어 줘요.
reveal: (api) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say({
ko: '"서버 점검"으로 가는 길의 가지를 모두 열고 선택했어요.',
en: 'Opened every branch on the way to "서버 점검" and selected it.',
});
},
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>시작할 때 열어 둘 가지 정하기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="reopen">처음 상태로</button>
<button type="button" id="reveal">깊은 줄로 가기</button>
<button type="button" id="expandAll">모두 열기</button>
<button type="button" id="collapseAll">모두 닫기</button>
</div>
<div id="grid" style="height: 330px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
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: 'T211',
parentId: 'T21',
task: '로그인 화면',
owner: '정하은',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: '목록 화면',
owner: '강지후',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: '백엔드',
owner: '최도윤',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API 설계',
owner: '최도윤',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: '데이터베이스 구성',
owner: '윤서아',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: '배포 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: '서버 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-18',
},
];
const options = {
columns: [
{ id: 'task', title: '작업', width: 220 },
{ id: 'owner', title: '담당자', width: 100 },
{ id: 'start', title: '시작', width: 110 },
{ id: 'end', title: '종료', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // 처음에는 모두 닫아 두고
};
let say = () => { };
// 시작할 때 열어 둘 가지와 눌러 둘 줄을 정해요. "출시 준비 > 개발 > 백엔드"가 열리고 백엔드가 선택돼요.
function openInitial(api) {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22'])
api.expandRow(key);
api.setSelectedKeys(['T22']);
}
function setup(api, log) {
say = log;
openInitial(api);
log({
ko: '"출시 준비 > 개발 > 백엔드"가 열린 채로 시작했고, 백엔드가 선택돼 있어요.',
en: 'Started with "출시 준비 > 개발 > 백엔드" open and Backend (백엔드) selected.',
});
}
const actions = {
reopen: (api) => {
openInitial(api);
say({ ko: '처음 상태로 되돌렸어요.', en: 'Back to the starting state.' });
},
// 깊이 숨어 있는 줄로 가려면 그 줄의 조상을 모두 열어야 해요. revealRow가 알아서 열어 줘요.
reveal: (api) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say({
ko: '"서버 점검"으로 가는 길의 가지를 모두 열고 선택했어요.',
en: 'Opened every branch on the way to "서버 점검" and selected it.',
});
},
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
};
options.ariaLabel = "시작할 때 열어 둘 가지 정하기";
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('reopen').addEventListener('click', () => actions.reopen(api));
document.getElementById('reveal').addEventListener('click', () => actions.reveal(api));
document.getElementById('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(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.reopen(api)}
>처음 상태로</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reveal(api)}
>깊은 줄로 가기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.expandAll(api)}
>모두 열기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.collapseAll(api)}
>모두 닫기</button>
</div>
<Grid style={{ height: 330 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: '로그인 화면',
owner: '정하은',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: '목록 화면',
owner: '강지후',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: '백엔드',
owner: '최도윤',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API 설계',
owner: '최도윤',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: '데이터베이스 구성',
owner: '윤서아',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: '배포 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: '서버 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 220 },
{ id: 'owner', title: '담당자', width: 100 },
{ id: 'start', title: '시작', width: 110 },
{ id: 'end', title: '종료', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // 처음에는 모두 닫아 두고
};
let say: (message: LogText) => void = () => {};
// 시작할 때 열어 둘 가지와 눌러 둘 줄을 정해요. "출시 준비 > 개발 > 백엔드"가 열리고 백엔드가 선택돼요.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log({
ko: '"출시 준비 > 개발 > 백엔드"가 열린 채로 시작했고, 백엔드가 선택돼 있어요.',
en: 'Started with "출시 준비 > 개발 > 백엔드" open and Backend (백엔드) selected.',
});
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say({ ko: '처음 상태로 되돌렸어요.', en: 'Back to the starting state.' });
},
// 깊이 숨어 있는 줄로 가려면 그 줄의 조상을 모두 열어야 해요. revealRow가 알아서 열어 줘요.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say({
ko: '"서버 점검"으로 가는 길의 가지를 모두 열고 선택했어요.',
en: 'Opened every branch on the way to "서버 점검" and selected it.',
});
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};버튼을 누르면 이 예제의 코드가 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.reopen(api)">처음 상태로</button>
<button type="button" :disabled="!api" @click="api && actions.reveal(api)">깊은 줄로 가기</button>
<button
type="button"
:disabled="!api"
@click="api && actions.expandAll(api)"
>모두 열기</button>
<button
type="button"
:disabled="!api"
@click="api && actions.collapseAll(api)"
>모두 닫기</button>
</div>
<Grid style="height: 330px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: '로그인 화면',
owner: '정하은',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: '목록 화면',
owner: '강지후',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: '백엔드',
owner: '최도윤',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API 설계',
owner: '최도윤',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: '데이터베이스 구성',
owner: '윤서아',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: '배포 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: '서버 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 220 },
{ id: 'owner', title: '담당자', width: 100 },
{ id: 'start', title: '시작', width: 110 },
{ id: 'end', title: '종료', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // 처음에는 모두 닫아 두고
};
let say: (message: LogText) => void = () => {};
// 시작할 때 열어 둘 가지와 눌러 둘 줄을 정해요. "출시 준비 > 개발 > 백엔드"가 열리고 백엔드가 선택돼요.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log({
ko: '"출시 준비 > 개발 > 백엔드"가 열린 채로 시작했고, 백엔드가 선택돼 있어요.',
en: 'Started with "출시 준비 > 개발 > 백엔드" open and Backend (백엔드) selected.',
});
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say({ ko: '처음 상태로 되돌렸어요.', en: 'Back to the starting state.' });
},
// 깊이 숨어 있는 줄로 가려면 그 줄의 조상을 모두 열어야 해요. revealRow가 알아서 열어 줘요.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say({
ko: '"서버 점검"으로 가는 길의 가지를 모두 열고 선택했어요.',
en: 'Opened every branch on the way to "서버 점검" and selected it.',
});
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};버튼을 누르면 이 예제의 코드가 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.reopen(api)"
>처음 상태로</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reveal(api)"
>깊은 줄로 가기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.expandAll(api)"
>모두 열기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.collapseAll(api)"
>모두 닫기</button>
</div>
<mx-grid style="height: 330px" [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: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: '로그인 화면',
owner: '정하은',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: '목록 화면',
owner: '강지후',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: '백엔드',
owner: '최도윤',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API 설계',
owner: '최도윤',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: '데이터베이스 구성',
owner: '윤서아',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: '배포 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: '서버 점검',
owner: '오세훈',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 220 },
{ id: 'owner', title: '담당자', width: 100 },
{ id: 'start', title: '시작', width: 110 },
{ id: 'end', title: '종료', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // 처음에는 모두 닫아 두고
};
let say: (message: LogText) => void = () => {};
// 시작할 때 열어 둘 가지와 눌러 둘 줄을 정해요. "출시 준비 > 개발 > 백엔드"가 열리고 백엔드가 선택돼요.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log({
ko: '"출시 준비 > 개발 > 백엔드"가 열린 채로 시작했고, 백엔드가 선택돼 있어요.',
en: 'Started with "출시 준비 > 개발 > 백엔드" open and Backend (백엔드) selected.',
});
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say({ ko: '처음 상태로 되돌렸어요.', en: 'Back to the starting state.' });
},
// 깊이 숨어 있는 줄로 가려면 그 줄의 조상을 모두 열어야 해요. revealRow가 알아서 열어 줘요.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say({
ko: '"서버 점검"으로 가는 길의 가지를 모두 열고 선택했어요.',
en: 'Opened every branch on the way to "서버 점검" and selected it.',
});
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};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="reopen">Back to start</button>
<button type="button" id="reveal">Jump to a deep row</button>
<button type="button" id="expandAll">Expand all</button>
<button type="button" id="collapseAll">Collapse all</button>
</div>
<div id="grid" style="height: 330px"></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('reopen').addEventListener('click', () => actions.reopen(api));
document.getElementById('reveal').addEventListener('click', () => actions.reveal(api));
document.getElementById('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(api));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: 'T211',
parentId: 'T21',
task: 'Login screen',
owner: 'Ava Moore',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: 'List screen',
owner: 'Jack Reed',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: 'Backend',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API design',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: 'Database setup',
owner: 'Chloe Young',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: 'Deployment check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: 'Server check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{ id: 'owner', title: 'Owner', width: 120 },
{ id: 'start', title: 'Start', width: 110 },
{ id: 'end', title: 'End', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // Start with everything closed
};
let say = () => { };
// Decide which branches start open and which row starts selected. "Release > Development > Backend" opens and Backend is selected.
function openInitial(api) {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22'])
api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api, log) {
say = log;
openInitial(api);
log('Started with "Release > Development > Backend" open and Backend selected.');
}
export const actions = {
reopen: (api) => {
openInitial(api);
say('Back to the starting state.');
},
// To reach a deeply hidden row, all of its ancestors must be open. revealRow opens them for you.
reveal: (api) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say('Opened every branch on the way to "Server check" and selected it.');
},
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Choose which branches start open</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="reopen">Back to start</button>
<button type="button" id="reveal">Jump to a deep row</button>
<button type="button" id="expandAll">Expand all</button>
<button type="button" id="collapseAll">Collapse all</button>
</div>
<div id="grid" style="height: 330px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
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: 'T211',
parentId: 'T21',
task: 'Login screen',
owner: 'Ava Moore',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: 'List screen',
owner: 'Jack Reed',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: 'Backend',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API design',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: 'Database setup',
owner: 'Chloe Young',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: 'Deployment check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: 'Server check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-18',
},
];
const options = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{ id: 'owner', title: 'Owner', width: 120 },
{ id: 'start', title: 'Start', width: 110 },
{ id: 'end', title: 'End', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // Start with everything closed
};
let say = () => { };
// Decide which branches start open and which row starts selected. "Release > Development > Backend" opens and Backend is selected.
function openInitial(api) {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22'])
api.expandRow(key);
api.setSelectedKeys(['T22']);
}
function setup(api, log) {
say = log;
openInitial(api);
log('Started with "Release > Development > Backend" open and Backend selected.');
}
const actions = {
reopen: (api) => {
openInitial(api);
say('Back to the starting state.');
},
// To reach a deeply hidden row, all of its ancestors must be open. revealRow opens them for you.
reveal: (api) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say('Opened every branch on the way to "Server check" and selected it.');
},
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
};
options.ariaLabel = "Choose which branches start open";
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('reopen').addEventListener('click', () => actions.reopen(api));
document.getElementById('reveal').addEventListener('click', () => actions.reveal(api));
document.getElementById('expandAll').addEventListener('click', () => actions.expandAll(api));
document.getElementById('collapseAll').addEventListener('click', () => actions.collapseAll(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.reopen(api)}
>Back to start</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reveal(api)}
>Jump to a deep row</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.expandAll(api)}
>Expand all</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.collapseAll(api)}
>Collapse all</button>
</div>
<Grid style={{ height: 330 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: 'Login screen',
owner: 'Ava Moore',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: 'List screen',
owner: 'Jack Reed',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: 'Backend',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API design',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: 'Database setup',
owner: 'Chloe Young',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: 'Deployment check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: 'Server check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{ id: 'owner', title: 'Owner', width: 120 },
{ id: 'start', title: 'Start', width: 110 },
{ id: 'end', title: 'End', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // Start with everything closed
};
let say: (message: LogText) => void = () => {};
// Decide which branches start open and which row starts selected. "Release > Development > Backend" opens and Backend is selected.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log('Started with "Release > Development > Backend" open and Backend selected.');
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say('Back to the starting state.');
},
// To reach a deeply hidden row, all of its ancestors must be open. revealRow opens them for you.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say('Opened every branch on the way to "Server check" and selected it.');
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};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.reopen(api)">Back to start</button>
<button type="button" :disabled="!api" @click="api && actions.reveal(api)">Jump to a deep row</button>
<button
type="button"
:disabled="!api"
@click="api && actions.expandAll(api)"
>Expand all</button>
<button
type="button"
:disabled="!api"
@click="api && actions.collapseAll(api)"
>Collapse all</button>
</div>
<Grid style="height: 330px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: 'Login screen',
owner: 'Ava Moore',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: 'List screen',
owner: 'Jack Reed',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: 'Backend',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API design',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: 'Database setup',
owner: 'Chloe Young',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: 'Deployment check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: 'Server check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{ id: 'owner', title: 'Owner', width: 120 },
{ id: 'start', title: 'Start', width: 110 },
{ id: 'end', title: 'End', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // Start with everything closed
};
let say: (message: LogText) => void = () => {};
// Decide which branches start open and which row starts selected. "Release > Development > Backend" opens and Backend is selected.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log('Started with "Release > Development > Backend" open and Backend selected.');
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say('Back to the starting state.');
},
// To reach a deeply hidden row, all of its ancestors must be open. revealRow opens them for you.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say('Opened every branch on the way to "Server check" and selected it.');
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};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.reopen(api)"
>Back to start</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reveal(api)"
>Jump to a deep row</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.expandAll(api)"
>Expand all</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.collapseAll(api)"
>Collapse all</button>
</div>
<mx-grid style="height: 330px" [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: string;
parentId: string | null;
task: string;
owner: string;
start: string;
end: string;
}
const rows: Row[] = [
{
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: 'T211',
parentId: 'T21',
task: 'Login screen',
owner: 'Ava Moore',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T212',
parentId: 'T21',
task: 'List screen',
owner: 'Jack Reed',
start: '2026-11-23',
end: '2026-11-27',
},
{
id: 'T22',
parentId: 'T20',
task: 'Backend',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-12-04',
},
{
id: 'T221',
parentId: 'T22',
task: 'API design',
owner: 'Noah Davis',
start: '2026-11-16',
end: '2026-11-20',
},
{
id: 'T222',
parentId: 'T22',
task: 'Database setup',
owner: 'Chloe Young',
start: '2026-11-23',
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',
},
{
id: 'T41',
parentId: 'T2',
task: 'Deployment check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-23',
},
{
id: 'T411',
parentId: 'T41',
task: 'Server check',
owner: 'Henry Ford',
start: '2026-12-14',
end: '2026-12-18',
},
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 220 },
{ id: 'owner', title: 'Owner', width: 120 },
{ id: 'start', title: 'Start', width: 110 },
{ id: 'end', title: 'End', width: 110 },
],
rows,
rowKey: 'id',
selection: 'single',
tree: { parentKey: 'parentId', column: 'task', expandDepth: 0 }, // Start with everything closed
};
let say: (message: LogText) => void = () => {};
// Decide which branches start open and which row starts selected. "Release > Development > Backend" opens and Backend is selected.
function openInitial(api: GridApi<Row>): void {
api.collapseAll();
for (const key of ['T1', 'T20', 'T22']) api.expandRow(key);
api.setSelectedKeys(['T22']);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
openInitial(api);
log('Started with "Release > Development > Backend" open and Backend selected.');
}
export const actions = {
reopen: (api: GridApi<Row>) => {
openInitial(api);
say('Back to the starting state.');
},
// To reach a deeply hidden row, all of its ancestors must be open. revealRow opens them for you.
reveal: (api: GridApi<Row>) => {
api.collapseAll();
api.revealRow('T411');
api.setSelectedKeys(['T411']);
api.scrollToRow('T411');
say('Opened every branch on the way to "Server check" and selected it.');
},
expandAll: (api: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
};