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

안내를 코드로 켜고 끄기Show and hide a notice from code

api.showOverlay로 행 수와 상관없이 안내를 보이고 api.hideOverlay로 자동 판단으로 돌아가요. 점검 중 같은 문구를 글자로 바로 줄 수도 있어요.api.showOverlay shows a notice regardless of the row count and api.hideOverlay returns to automatic. You can also pass a plain text such as a maintenance message.

활용Intermediate
직접 써 보기Live preview안내를 코드로 켜고 끄기Show and hide a notice from code

코드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)

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

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

index.html
<div id="app">
  <div class="toolbar">
    <button type="button" id="loading">로딩 보이기</button>
    <button type="button" id="maintenance">점검 중 보이기</button>
    <button type="button" id="hide">숨기기</button>
  </div>
  <div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('maintenance').addEventListener('click', () => actions.maintenance(api));
document.getElementById('hide').addEventListener('click', () => actions.hide(api));
example.js
// showOverlay는 행 수와 상관없이 안내를 지금 보이는 본문 위에 덮고, hideOverlay로 자동 판단으로 돌아가요.
export const options = {
  columns: [{ id: 'name', title: '이름', width: 160 }],
  rows: [
    { id: 1, name: '김서연' },
    { id: 2, name: '이준호' },
    { id: 3, name: '박민지' },
  ],
  rowKey: 'id',
};
export function setup(_grid, log) {
  log({
    ko: '버튼으로 안내를 켜고 꺼 보세요.',
    en: 'Use the buttons to turn a notice on and off.',
  });
}
export const actions = {
  loading: (grid) => grid.showOverlay('loading'),
  maintenance: (grid) => grid.showOverlay('점검 중이에요. 잠시 뒤에 다시 시도해 주세요.'),
  hide: (grid) => grid.hideOverlay(),
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div class="toolbar">
    <button type="button" id="loading">Show loading</button>
    <button type="button" id="maintenance">Show maintenance</button>
    <button type="button" id="hide">Hide</button>
  </div>
  <div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('loading').addEventListener('click', () => actions.loading(api));
document.getElementById('maintenance').addEventListener('click', () => actions.maintenance(api));
document.getElementById('hide').addEventListener('click', () => actions.hide(api));
example.js
// showOverlay covers the currently visible body with a notice regardless of the row count, and hideOverlay returns to the automatic decision.
export const options = {
  columns: [{ id: 'name', title: 'Name', width: 160 }],
  rows: [
    { id: 1, name: 'Emma Stone' },
    { id: 2, name: 'Liam Carter' },
    { id: 3, name: 'Olivia Hayes' },
  ],
  rowKey: 'id',
};
export function setup(_grid, log) {
  log('Use the buttons to turn a notice on and off.');
}
export const actions = {
  loading: (grid) => grid.showOverlay('loading'),
  maintenance: (grid) => grid.showOverlay('Under maintenance. Please try again in a moment.'),
  hide: (grid) => grid.hideOverlay(),
};