트리를 펼칠 때의 움직임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.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<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>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));// 번호(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 }),
};<!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="expandAll">모두 열기</button>
<button type="button" id="collapseAll">모두 닫기</button>
<button type="button" id="motion">움직임 켜기·끄기</button>
</div>
<div id="grid" style="height: 430px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 번호(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',
},
];
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,
};
const actions = {
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};
options.ariaLabel = "트리를 펼칠 때의 움직임";
const api = MaxGrid.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));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.expandAll(api)}
>모두 열기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.collapseAll(api)}
>모두 닫기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.motion(api)}
>움직임 켜기·끄기</button>
</div>
<Grid style={{ height: 430 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// 번호(code)가 첫 컬럼이고, 펼침 화살표는 두 번째 컬럼인 "작업"에 붙어요.
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<button
type="button"
:disabled="!api"
@click="api && actions.expandAll(api)"
>모두 열기</button>
<button
type="button"
:disabled="!api"
@click="api && actions.collapseAll(api)"
>모두 닫기</button>
<button type="button" :disabled="!api" @click="api && actions.motion(api)">움직임 켜기·끄기</button>
</div>
<Grid style="height: 430px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// 번호(code)가 첫 컬럼이고, 펼침 화살표는 두 번째 컬럼인 "작업"에 붙어요.
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, 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.expandAll(api)"
>모두 열기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.collapseAll(api)"
>모두 닫기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.motion(api)"
>움직임 켜기·끄기</button>
</div>
<mx-grid style="height: 430px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// 번호(code)가 첫 컬럼이고, 펼침 화살표는 두 번째 컬럼인 "작업"에 붙어요.
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};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="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>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));// 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 }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Motion when a tree opens</title>
</head>
<body>
<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>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 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',
},
];
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,
};
const actions = {
expandAll: (api) => api.expandAll(),
collapseAll: (api) => api.collapseAll(),
motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};
options.ariaLabel = "Motion when a tree opens";
const api = MaxGrid.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));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<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>
<button
type="button"
disabled={!api}
onClick={() => api && actions.motion(api)}
>Motion on/off</button>
</div>
<Grid style={{ height: 430 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// The code is the first column, and the expand arrow sits on the second column, "Task".
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<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>
<button type="button" :disabled="!api" @click="api && actions.motion(api)">Motion on/off</button>
</div>
<Grid style="height: 430px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// The code is the first column, and the expand arrow sits on the second column, "Task".
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, 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.expandAll(api)"
>Expand all</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.collapseAll(api)"
>Collapse all</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.motion(api)"
>Motion on/off</button>
</div>
<mx-grid style="height: 430px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: string;
parentId: string | null;
code: string;
task: string;
owner: string;
end: string;
}
// The code is the first column, and the expand arrow sits on the second column, "Task".
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>) => api.expandAll(),
collapseAll: (api: GridApi<Row>) => api.collapseAll(),
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};