빈 목록·불러오는 중 안내 문구 바꾸기Change the empty and loading messages
결과가 없을 때와 불러오는 중에 보이는 안내 문구는 언어에 따라 기본 문구가 달라지고, 원하는 말로 직접 바꿔 쓸 수도 있어요. 필터로 가려진 경우와 데이터가 아예 없는 경우 모두 같은 빈 목록 문구가 나와요.The texts for an empty result and for loading follow the language, and you can replace each with your own wording. The same empty text shows whether a filter hides every row or there is no data at all.
코드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="noMatch">일치하는 행 없음</button>
<button type="button" id="noData">데이터 비우기</button>
<button type="button" id="loading">불러오는 중 보기</button>
<button type="button" id="restore">원래대로</button>
<select aria-label="언어" id="locale">
<option value="ko" selected>한국어 (기본)</option>
<option value="en">English</option>
</select>
<select aria-label="안내 문구" id="wording">
<option value="builtin" selected>기본 문구 (기본)</option>
<option value="custom">내 문구</option>
</select>
</div>
<div id="grid" style="height: 260px"></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);
document.getElementById('noMatch').addEventListener('click', () => actions.noMatch(api));
document.getElementById('noData').addEventListener('click', () => actions.noData(api));
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('restore').addEventListener('click', () => actions.restore(api));
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
document.getElementById('wording').addEventListener('change', (event) => actions.wording(api, event.target.value));// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
const ROWS = [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
{ id: 4, name: '최유나', dept: '개발팀' },
];
// locale은 기본 문구(빈 목록, 불러오는 중)의 언어를 정하고, messages는 그 위에 문구 하나하나를 덮어써요.
const CUSTOM = {
noRows: L('조건에 맞는 직원이 없어요.', 'No employee matches.'),
loading: L('직원 목록을 불러오는 중…', 'Loading the employee list…'),
};
export const options = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'ko',
};
let timer;
export function setup(_api) {
return () => clearTimeout(timer);
}
export const actions = {
// 필터가 모든 행을 가려도 데이터는 그대로 있어요. 필터를 풀면 돌아와요.
noMatch: (api) => api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// 데이터 자체가 비면 같은 빈 목록 문구가 나와요.
noData: (api) => api.setRows([]),
restore: (api) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed())
api.setOptions({ loading: false });
}, 1500);
},
locale: (api, value) => {
if (value === 'ko' || value === 'en')
api.setOptions({ locale: value });
},
wording: (api, value) => api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};<!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="noMatch">일치하는 행 없음</button>
<button type="button" id="noData">데이터 비우기</button>
<button type="button" id="loading">불러오는 중 보기</button>
<button type="button" id="restore">원래대로</button>
<select aria-label="언어" id="locale">
<option value="ko" selected>한국어 (기본)</option>
<option value="en">English</option>
</select>
<select aria-label="안내 문구" id="wording">
<option value="builtin" selected>기본 문구 (기본)</option>
<option value="custom">내 문구</option>
</select>
</div>
<div id="grid" style="height: 260px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
const ROWS = [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
{ id: 4, name: '최유나', dept: '개발팀' },
];
// locale은 기본 문구(빈 목록, 불러오는 중)의 언어를 정하고, messages는 그 위에 문구 하나하나를 덮어써요.
const CUSTOM = {
noRows: L('조건에 맞는 직원이 없어요.', 'No employee matches.'),
loading: L('직원 목록을 불러오는 중…', 'Loading the employee list…'),
};
const options = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'ko',
};
let timer;
function setup(_api) {
return () => clearTimeout(timer);
}
const actions = {
// 필터가 모든 행을 가려도 데이터는 그대로 있어요. 필터를 풀면 돌아와요.
noMatch: (api) => api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// 데이터 자체가 비면 같은 빈 목록 문구가 나와요.
noData: (api) => api.setRows([]),
restore: (api) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed())
api.setOptions({ loading: false });
}, 1500);
},
locale: (api, value) => {
if (value === 'ko' || value === 'en')
api.setOptions({ locale: value });
},
wording: (api, value) => api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};
options.ariaLabel = "빈 목록·불러오는 중 안내 문구 바꾸기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api);
document.getElementById('noMatch').addEventListener('click', () => actions.noMatch(api));
document.getElementById('noData').addEventListener('click', () => actions.noData(api));
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('restore').addEventListener('click', () => actions.restore(api));
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
document.getElementById('wording').addEventListener('change', (event) => actions.wording(api, event.target.value));
</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) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.noMatch(api)}
>일치하는 행 없음</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.noData(api)}
>데이터 비우기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.loading(api)}
>불러오는 중 보기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.restore(api)}
>원래대로</button>
<select
aria-label="언어"
disabled={!api}
onChange={(event) => api && actions.locale(api, event.target.value)}
>
<option value="ko">한국어 (기본)</option>
<option value="en">English</option>
</select>
<select defaultValue="ko"
aria-label="안내 문구"
disabled={!api}
onChange={(event) => api && actions.wording(api, event.target.value)}
>
<option value="builtin">기본 문구 (기본)</option>
<option value="custom">내 문구</option>
</select>
</div>
<Grid style={{ height: 260 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridLocale, GridOptions } from '@maxgrid/react';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
{ id: 4, name: '최유나', dept: '개발팀' },
];
// locale은 기본 문구(빈 목록, 불러오는 중)의 언어를 정하고, messages는 그 위에 문구 하나하나를 덮어써요.
const CUSTOM = {
noRows: L('조건에 맞는 직원이 없어요.', 'No employee matches.'),
loading: L('직원 목록을 불러오는 중…', 'Loading the employee list…'),
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'ko',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// 필터가 모든 행을 가려도 데이터는 그대로 있어요. 필터를 풀면 돌아와요.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// 데이터 자체가 비면 같은 빈 목록 문구가 나와요.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};버튼을 누르면 이 예제의 코드가 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);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.noMatch(api)">일치하는 행 없음</button>
<button type="button" :disabled="!api" @click="api && actions.noData(api)">데이터 비우기</button>
<button type="button" :disabled="!api" @click="api && actions.loading(api)">불러오는 중 보기</button>
<button type="button" :disabled="!api" @click="api && actions.restore(api)">원래대로</button>
<select
aria-label="언어"
:disabled="!api"
@change="api && actions.locale(api, ($event.target as HTMLSelectElement).value)"
>
<option value="ko" selected>한국어 (기본)</option>
<option value="en">English</option>
</select>
<select
aria-label="안내 문구"
:disabled="!api"
@change="api && actions.wording(api, ($event.target as HTMLSelectElement).value)"
>
<option value="builtin" selected>기본 문구 (기본)</option>
<option value="custom">내 문구</option>
</select>
</div>
<Grid style="height: 260px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridLocale, GridOptions } from '@maxgrid/vue';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
{ id: 4, name: '최유나', dept: '개발팀' },
];
// locale은 기본 문구(빈 목록, 불러오는 중)의 언어를 정하고, messages는 그 위에 문구 하나하나를 덮어써요.
const CUSTOM = {
noRows: L('조건에 맞는 직원이 없어요.', 'No employee matches.'),
loading: L('직원 목록을 불러오는 중…', 'Loading the employee list…'),
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'ko',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// 필터가 모든 행을 가려도 데이터는 그대로 있어요. 필터를 풀면 돌아와요.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// 데이터 자체가 비면 같은 빈 목록 문구가 나와요.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};버튼을 누르면 이 예제의 코드가 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.noMatch(api)"
>일치하는 행 없음</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.noData(api)"
>데이터 비우기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.loading(api)"
>불러오는 중 보기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.restore(api)"
>원래대로</button>
<select
aria-label="언어"
[disabled]="!api"
(change)="api && actions.locale(api, $any($event.target).value)"
>
<option value="ko" selected>한국어 (기본)</option>
<option value="en">English</option>
</select>
<select
aria-label="안내 문구"
[disabled]="!api"
(change)="api && actions.wording(api, $any($event.target).value)"
>
<option value="builtin" selected>기본 문구 (기본)</option>
<option value="custom">내 문구</option>
</select>
</div>
<mx-grid style="height: 260px" [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);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridLocale, GridOptions } from '@maxgrid/angular';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
{ id: 4, name: '최유나', dept: '개발팀' },
];
// locale은 기본 문구(빈 목록, 불러오는 중)의 언어를 정하고, messages는 그 위에 문구 하나하나를 덮어써요.
const CUSTOM = {
noRows: L('조건에 맞는 직원이 없어요.', 'No employee matches.'),
loading: L('직원 목록을 불러오는 중…', 'Loading the employee list…'),
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'ko',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// 필터가 모든 행을 가려도 데이터는 그대로 있어요. 필터를 풀면 돌아와요.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// 데이터 자체가 비면 같은 빈 목록 문구가 나와요.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};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="noMatch">No matching rows</button>
<button type="button" id="noData">Empty the data</button>
<button type="button" id="loading">Show loading</button>
<button type="button" id="restore">Restore</button>
<select aria-label="Language" id="locale">
<option value="ko" selected>Korean (default)</option>
<option value="en">English</option>
</select>
<select aria-label="Wording" id="wording">
<option value="builtin" selected>Built-in (default)</option>
<option value="custom">Custom</option>
</select>
</div>
<div id="grid" style="height: 260px"></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);
document.getElementById('noMatch').addEventListener('click', () => actions.noMatch(api));
document.getElementById('noData').addEventListener('click', () => actions.noData(api));
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('restore').addEventListener('click', () => actions.restore(api));
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
document.getElementById('wording').addEventListener('change', (event) => actions.wording(api, event.target.value));const ROWS = [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Parker', dept: 'Sales' },
{ id: 4, name: 'Olivia Reed', dept: 'Dev' },
];
// locale sets the language of the default messages (empty list, loading), and messages overrides each message on top of it.
const CUSTOM = {
noRows: 'No employee matches.',
loading: 'Loading the employee list…',
};
export const options = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Dept', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'en',
};
let timer;
export function setup(_api) {
return () => clearTimeout(timer);
}
export const actions = {
// Even when the filter hides every row, the data is still there. Clear the filter and the rows come back.
noMatch: (api) => api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// If the data itself is empty, the same empty-list message appears.
noData: (api) => api.setRows([]),
restore: (api) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed())
api.setOptions({ loading: false });
}, 1500);
},
locale: (api, value) => {
if (value === 'ko' || value === 'en')
api.setOptions({ locale: value });
},
wording: (api, value) => api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Change the empty and loading messages</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="noMatch">No matching rows</button>
<button type="button" id="noData">Empty the data</button>
<button type="button" id="loading">Show loading</button>
<button type="button" id="restore">Restore</button>
<select aria-label="Language" id="locale">
<option value="ko" selected>Korean (default)</option>
<option value="en">English</option>
</select>
<select aria-label="Wording" id="wording">
<option value="builtin" selected>Built-in (default)</option>
<option value="custom">Custom</option>
</select>
</div>
<div id="grid" style="height: 260px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const ROWS = [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Parker', dept: 'Sales' },
{ id: 4, name: 'Olivia Reed', dept: 'Dev' },
];
// locale sets the language of the default messages (empty list, loading), and messages overrides each message on top of it.
const CUSTOM = {
noRows: 'No employee matches.',
loading: 'Loading the employee list…',
};
const options = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Dept', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'en',
};
let timer;
function setup(_api) {
return () => clearTimeout(timer);
}
const actions = {
// Even when the filter hides every row, the data is still there. Clear the filter and the rows come back.
noMatch: (api) => api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// If the data itself is empty, the same empty-list message appears.
noData: (api) => api.setRows([]),
restore: (api) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed())
api.setOptions({ loading: false });
}, 1500);
},
locale: (api, value) => {
if (value === 'ko' || value === 'en')
api.setOptions({ locale: value });
},
wording: (api, value) => api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};
options.ariaLabel = "Change the empty and loading messages";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api);
document.getElementById('noMatch').addEventListener('click', () => actions.noMatch(api));
document.getElementById('noData').addEventListener('click', () => actions.noData(api));
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('restore').addEventListener('click', () => actions.restore(api));
document.getElementById('locale').addEventListener('change', (event) => actions.locale(api, event.target.value));
document.getElementById('wording').addEventListener('change', (event) => actions.wording(api, event.target.value));
</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) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.noMatch(api)}
>No matching rows</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.noData(api)}
>Empty the data</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.loading(api)}
>Show loading</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.restore(api)}
>Restore</button>
<select
aria-label="Language"
disabled={!api}
onChange={(event) => api && actions.locale(api, event.target.value)}
>
<option value="ko">Korean (default)</option>
<option value="en">English</option>
</select>
<select defaultValue="ko"
aria-label="Wording"
disabled={!api}
onChange={(event) => api && actions.wording(api, event.target.value)}
>
<option value="builtin">Built-in (default)</option>
<option value="custom">Custom</option>
</select>
</div>
<Grid style={{ height: 260 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridLocale, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Parker', dept: 'Sales' },
{ id: 4, name: 'Olivia Reed', dept: 'Dev' },
];
// locale sets the language of the default messages (empty list, loading), and messages overrides each message on top of it.
const CUSTOM = {
noRows: 'No employee matches.',
loading: 'Loading the employee list…',
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Dept', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'en',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// Even when the filter hides every row, the data is still there. Clear the filter and the rows come back.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// If the data itself is empty, the same empty-list message appears.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};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);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.noMatch(api)">No matching rows</button>
<button type="button" :disabled="!api" @click="api && actions.noData(api)">Empty the data</button>
<button type="button" :disabled="!api" @click="api && actions.loading(api)">Show loading</button>
<button type="button" :disabled="!api" @click="api && actions.restore(api)">Restore</button>
<select
aria-label="Language"
:disabled="!api"
@change="api && actions.locale(api, ($event.target as HTMLSelectElement).value)"
>
<option value="ko" selected>Korean (default)</option>
<option value="en">English</option>
</select>
<select
aria-label="Wording"
:disabled="!api"
@change="api && actions.wording(api, ($event.target as HTMLSelectElement).value)"
>
<option value="builtin" selected>Built-in (default)</option>
<option value="custom">Custom</option>
</select>
</div>
<Grid style="height: 260px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridLocale, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Parker', dept: 'Sales' },
{ id: 4, name: 'Olivia Reed', dept: 'Dev' },
];
// locale sets the language of the default messages (empty list, loading), and messages overrides each message on top of it.
const CUSTOM = {
noRows: 'No employee matches.',
loading: 'Loading the employee list…',
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Dept', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'en',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// Even when the filter hides every row, the data is still there. Clear the filter and the rows come back.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// If the data itself is empty, the same empty-list message appears.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};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.noMatch(api)"
>No matching rows</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.noData(api)"
>Empty the data</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.loading(api)"
>Show loading</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.restore(api)"
>Restore</button>
<select
aria-label="Language"
[disabled]="!api"
(change)="api && actions.locale(api, $any($event.target).value)"
>
<option value="ko" selected>Korean (default)</option>
<option value="en">English</option>
</select>
<select
aria-label="Wording"
[disabled]="!api"
(change)="api && actions.wording(api, $any($event.target).value)"
>
<option value="builtin" selected>Built-in (default)</option>
<option value="custom">Custom</option>
</select>
</div>
<mx-grid style="height: 260px" [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);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridLocale, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
dept: string;
}
const ROWS: Row[] = [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Parker', dept: 'Sales' },
{ id: 4, name: 'Olivia Reed', dept: 'Dev' },
];
// locale sets the language of the default messages (empty list, loading), and messages overrides each message on top of it.
const CUSTOM = {
noRows: 'No employee matches.',
loading: 'Loading the employee list…',
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Dept', width: 150 },
],
rows: ROWS,
rowKey: 'id',
locale: 'en',
};
let timer: ReturnType<typeof setTimeout> | undefined;
export function setup(_api: GridApi<Row>) {
return () => clearTimeout(timer);
}
export const actions = {
// Even when the filter hides every row, the data is still there. Clear the filter and the rows come back.
noMatch: (api: GridApi<Row>) =>
api.setFilterModel({
match: 'all',
items: [{ columnId: 'name', operator: 'contains', value: 'zzz' }],
}),
// If the data itself is empty, the same empty-list message appears.
noData: (api: GridApi<Row>) => api.setRows([]),
restore: (api: GridApi<Row>) => {
api.setFilterModel(null);
api.setRows(ROWS);
},
loading: (api: GridApi<Row>) => {
api.setOptions({ loading: true });
clearTimeout(timer);
timer = setTimeout(() => {
if (!api.isDestroyed()) api.setOptions({ loading: false });
}, 1500);
},
locale: (api: GridApi<Row>, value?: string) => {
if (value === 'ko' || value === 'en') api.setOptions({ locale: value satisfies GridLocale });
},
wording: (api: GridApi<Row>, value?: string) =>
api.setOptions({ messages: value === 'custom' ? CUSTOM : {} }),
};