행이 미끄러지는 움직임Rows that slide
motion: true면 정렬·행 추가·삭제에서 행이 제자리로 미끄러지고, 새 행은 나타나며, 지운 행은 사라져요. 필터 메뉴 같은 팝업도 부드럽게 열려요. 기본은 꺼져 있고 모션 줄이기 설정을 따라요.With motion: true rows slide into place on sort, add and remove, new rows fade in and removed rows fade out. Popups such as the filter menu open softly. It is off by default and follows the reduced-motion setting.
코드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="sort">정렬 바꾸기</button>
<button type="button" id="add">행 추가</button>
<button type="button" id="remove">행 삭제</button>
<button type="button" id="motion">움직임 켜기·끄기</button>
</div>
<div id="grid" style="height: 440px"></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('sort').addEventListener('click', () => actions.sort(api));
document.getElementById('add').addEventListener('click', () => actions.add(api));
document.getElementById('remove').addEventListener('click', () => actions.remove(api));
document.getElementById('motion').addEventListener('click', () => actions.motion(api));const en = document.documentElement.dataset.lang === 'en';
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `${en ? 'Item' : '항목'} ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options = {
columns: [
{ id: 'name', title: en ? 'Name' : '이름', width: 160, sortable: true },
{ id: 'score', title: en ? 'Score' : '점수', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// motion: true면 정렬·추가·삭제에서 행이 미끄러지고 팝업이 부드럽게 열려요(기본은 꺼짐).
motion: true,
};
export const actions = {
add: (api) => {
nextId += 1;
api.addRows([{ id: nextId, name: `${en ? 'New' : '새 항목'} ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api) => {
const row = api.getVisibleRows()[2];
if (row)
api.removeRows([row.id]);
},
sort: (api) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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="sort">정렬 바꾸기</button>
<button type="button" id="add">행 추가</button>
<button type="button" id="remove">행 삭제</button>
<button type="button" id="motion">움직임 켜기·끄기</button>
</div>
<div id="grid" style="height: 440px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const en = document.documentElement.dataset.lang === 'en';
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `${en ? 'Item' : '항목'} ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
const options = {
columns: [
{ id: 'name', title: en ? 'Name' : '이름', width: 160, sortable: true },
{ id: 'score', title: en ? 'Score' : '점수', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// motion: true면 정렬·추가·삭제에서 행이 미끄러지고 팝업이 부드럽게 열려요(기본은 꺼짐).
motion: true,
};
const actions = {
add: (api) => {
nextId += 1;
api.addRows([{ id: nextId, name: `${en ? 'New' : '새 항목'} ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api) => {
const row = api.getVisibleRows()[2];
if (row)
api.removeRows([row.id]);
},
sort: (api) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};
options.ariaLabel = "행이 미끄러지는 움직임";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('sort').addEventListener('click', () => actions.sort(api));
document.getElementById('add').addEventListener('click', () => actions.add(api));
document.getElementById('remove').addEventListener('click', () => actions.remove(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.sort(api)}
>정렬 바꾸기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.add(api)}
>행 추가</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.remove(api)}
>행 삭제</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.motion(api)}
>움직임 켜기·끄기</button>
</div>
<Grid style={{ height: 440 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
score: number;
}
const en = document.documentElement.dataset.lang === 'en';
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `${en ? 'Item' : '항목'} ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: en ? 'Name' : '이름', width: 160, sortable: true },
{ id: 'score', title: en ? 'Score' : '점수', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// motion: true면 정렬·추가·삭제에서 행이 미끄러지고 팝업이 부드럽게 열려요(기본은 꺼짐).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows(
[{ id: nextId, name: `${en ? 'New' : '새 항목'} ${nextId}`, score: nextId % 100 }],
2,
);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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.sort(api)">정렬 바꾸기</button>
<button type="button" :disabled="!api" @click="api && actions.add(api)">행 추가</button>
<button type="button" :disabled="!api" @click="api && actions.remove(api)">행 삭제</button>
<button type="button" :disabled="!api" @click="api && actions.motion(api)">움직임 켜기·끄기</button>
</div>
<Grid style="height: 440px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
score: number;
}
const en = document.documentElement.dataset.lang === 'en';
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `${en ? 'Item' : '항목'} ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: en ? 'Name' : '이름', width: 160, sortable: true },
{ id: 'score', title: en ? 'Score' : '점수', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// motion: true면 정렬·추가·삭제에서 행이 미끄러지고 팝업이 부드럽게 열려요(기본은 꺼짐).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows(
[{ id: nextId, name: `${en ? 'New' : '새 항목'} ${nextId}`, score: nextId % 100 }],
2,
);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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.sort(api)"
>정렬 바꾸기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.add(api)"
>행 추가</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.remove(api)"
>행 삭제</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.motion(api)"
>움직임 켜기·끄기</button>
</div>
<mx-grid style="height: 440px" [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: number;
name: string;
score: number;
}
const en = document.documentElement.dataset.lang === 'en';
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `${en ? 'Item' : '항목'} ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: en ? 'Name' : '이름', width: 160, sortable: true },
{ id: 'score', title: en ? 'Score' : '점수', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// motion: true면 정렬·추가·삭제에서 행이 미끄러지고 팝업이 부드럽게 열려요(기본은 꺼짐).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows(
[{ id: nextId, name: `${en ? 'New' : '새 항목'} ${nextId}`, score: nextId % 100 }],
2,
);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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="sort">Toggle sort</button>
<button type="button" id="add">Add row</button>
<button type="button" id="remove">Remove row</button>
<button type="button" id="motion">Motion on/off</button>
</div>
<div id="grid" style="height: 440px"></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('sort').addEventListener('click', () => actions.sort(api));
document.getElementById('add').addEventListener('click', () => actions.add(api));
document.getElementById('remove').addEventListener('click', () => actions.remove(api));
document.getElementById('motion').addEventListener('click', () => actions.motion(api));const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `Item ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options = {
columns: [
{ id: 'name', title: 'Name', width: 160, sortable: true },
{ id: 'score', title: 'Score', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// With motion: true, rows slide on sort, add and remove, and popups open smoothly (off by default).
motion: true,
};
export const actions = {
add: (api) => {
nextId += 1;
api.addRows([{ id: nextId, name: `New ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api) => {
const row = api.getVisibleRows()[2];
if (row)
api.removeRows([row.id]);
},
sort: (api) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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>Rows that slide</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="sort">Toggle sort</button>
<button type="button" id="add">Add row</button>
<button type="button" id="remove">Remove row</button>
<button type="button" id="motion">Motion on/off</button>
</div>
<div id="grid" style="height: 440px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `Item ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
const options = {
columns: [
{ id: 'name', title: 'Name', width: 160, sortable: true },
{ id: 'score', title: 'Score', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// With motion: true, rows slide on sort, add and remove, and popups open smoothly (off by default).
motion: true,
};
const actions = {
add: (api) => {
nextId += 1;
api.addRows([{ id: nextId, name: `New ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api) => {
const row = api.getVisibleRows()[2];
if (row)
api.removeRows([row.id]);
},
sort: (api) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
motion: (api) => api.setOptions({ motion: !api.getOptions().motion }),
};
options.ariaLabel = "Rows that slide";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('sort').addEventListener('click', () => actions.sort(api));
document.getElementById('add').addEventListener('click', () => actions.add(api));
document.getElementById('remove').addEventListener('click', () => actions.remove(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.sort(api)}
>Toggle sort</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.add(api)}
>Add row</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.remove(api)}
>Remove row</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.motion(api)}
>Motion on/off</button>
</div>
<Grid style={{ height: 440 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `Item ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 160, sortable: true },
{ id: 'score', title: 'Score', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// With motion: true, rows slide on sort, add and remove, and popups open smoothly (off by default).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows([{ id: nextId, name: `New ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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.sort(api)">Toggle sort</button>
<button type="button" :disabled="!api" @click="api && actions.add(api)">Add row</button>
<button type="button" :disabled="!api" @click="api && actions.remove(api)">Remove row</button>
<button type="button" :disabled="!api" @click="api && actions.motion(api)">Motion on/off</button>
</div>
<Grid style="height: 440px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `Item ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 160, sortable: true },
{ id: 'score', title: 'Score', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// With motion: true, rows slide on sort, add and remove, and popups open smoothly (off by default).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows([{ id: nextId, name: `New ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
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.sort(api)"
>Toggle sort</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.add(api)"
>Add row</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.remove(api)"
>Remove row</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.motion(api)"
>Motion on/off</button>
</div>
<mx-grid style="height: 440px" [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: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: `Item ${String.fromCharCode(65 + i)}`,
score: (i * 37) % 100,
}));
let nextId = 100;
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 160, sortable: true },
{ id: 'score', title: 'Score', kind: 'number', width: 110, sortable: true },
],
rows,
rowKey: 'id',
// With motion: true, rows slide on sort, add and remove, and popups open smoothly (off by default).
motion: true,
};
export const actions = {
add: (api: GridApi<Row>) => {
nextId += 1;
api.addRows([{ id: nextId, name: `New ${nextId}`, score: nextId % 100 }], 2);
},
remove: (api: GridApi<Row>) => {
const row = api.getVisibleRows()[2];
if (row) api.removeRows([row.id]);
},
sort: (api: GridApi<Row>) => {
const asc = api.getSortModel()[0]?.direction !== 'asc';
api.setSortModel([{ columnId: 'score', direction: asc ? 'asc' : 'desc' }]);
},
motion: (api: GridApi<Row>) => api.setOptions({ motion: !api.getOptions().motion }),
};