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

메모 말풍선만 따로 조정하기Tune only the note tooltip

cellNoteOptions { trigger, showDelay, hideDelay }는 셀 메모의 말풍선에만 적용돼요. 컬럼 말풍선(품목 칸·수량 머리글)은 기본 설정 그대로예요. 생략한 값은 tooltipOptions·tooltipDelay를 따라요.cellNoteOptions { trigger, showDelay, hideDelay } applies only to the tooltip of cell notes. Column tooltips (the item cells and the quantity header) keep the default settings. Omitted values follow tooltipOptions and tooltipDelay.

활용Intermediate
직접 써 보기Live preview메모 말풍선만 따로 조정하기Tune only the note tooltip

코드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="show">메모 보기</button>
    <button type="button" id="fast">메모 바로 보이기</button>
    <button type="button" id="slow">메모 천천히</button>
    <button type="button" id="inherit">기본 따르기</button>
  </div>
  <div id="grid" style="height: 200px"></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('show').addEventListener('click', () => actions.show(api));
document.getElementById('fast').addEventListener('click', () => actions.fast(api));
document.getElementById('slow').addEventListener('click', () => actions.slow(api));
document.getElementById('inherit').addEventListener('click', () => actions.inherit(api));
example.js
const en = document.documentElement.dataset.lang === 'en';
const names = en ? ['Pen', 'Notebook', 'Stapler', 'Tape'] : ['펜', '노트', '스테이플러', '테이프'];
export const options = {
  columns: [
    { id: 'name', title: en ? 'Item' : '품목', width: 130, tooltip: true },
    {
      id: 'qty',
      title: en ? 'Qty' : '수량',
      kind: 'number',
      width: 90,
      headerTooltip: en ? 'Quantity in stock' : '재고 수량',
    },
  ],
  rows: names.map((name, i) => ({ id: i + 1, name, qty: 10 + i * 4 })),
  rowKey: 'id',
  cellSelection: 'single',
  cellNotes: [
    { rowKey: 1, columnId: 'qty', text: en ? 'Check the count' : '수량 확인 필요' },
    { rowKey: 3, columnId: 'qty', text: en ? 'Reorder soon' : '곧 재주문' },
  ],
  // 일반 말풍선은 기본 설정을 쓰고(120ms, 마우스), 메모만 느리게 나타나고 오래 남아요.
  cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 },
};
let say = () => { };
export function setup(api, log) {
  say = log;
  const off = api.on('tooltipShown', (e) => say({ ko: `말풍선(${e.target}) 표시`, en: `Tooltip (${e.target}) shown` }));
  return off;
}
export const actions = {
  // 터치에서도 메모를 볼 수 있게, 메모 칸에 포커스를 줘서 보여요(trigger: 'both'면 포커스로도 나타나요).
  show: (api) => {
    api.focusCell(1, 'qty');
    say({
      ko: '1번 행 수량 칸에 포커스: 지연(showDelay) 뒤 메모가 나타나요',
      en: 'Focused the quantity cell of row 1: the note appears after showDelay',
    });
  },
  fast: (api) => {
    api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
    say({ ko: '메모: 바로 나타나고 바로 사라져요', en: 'Notes: instant show and hide' });
  },
  slow: (api) => {
    api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
    say({ ko: '메모: 600ms 뒤 나타나고 800ms 남아요', en: 'Notes: show after 600ms, stay 800ms' });
  },
  inherit: (api) => {
    api.setOptions({ cellNoteOptions: {} });
    say({
      ko: '메모도 일반 말풍선 설정을 따라요',
      en: 'Notes follow the normal tooltip settings again',
    });
  },
};

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="show">Show note</button>
    <button type="button" id="fast">Instant notes</button>
    <button type="button" id="slow">Slow notes</button>
    <button type="button" id="inherit">Follow defaults</button>
  </div>
  <div id="grid" style="height: 200px"></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('show').addEventListener('click', () => actions.show(api));
document.getElementById('fast').addEventListener('click', () => actions.fast(api));
document.getElementById('slow').addEventListener('click', () => actions.slow(api));
document.getElementById('inherit').addEventListener('click', () => actions.inherit(api));
example.js
const names = ['Pen', 'Notebook', 'Stapler', 'Tape'];
export const options = {
  columns: [
    { id: 'name', title: 'Item', width: 130, tooltip: true },
    {
      id: 'qty',
      title: 'Qty',
      kind: 'number',
      width: 90,
      headerTooltip: 'Quantity in stock',
    },
  ],
  rows: names.map((name, i) => ({ id: i + 1, name, qty: 10 + i * 4 })),
  rowKey: 'id',
  cellSelection: 'single',
  cellNotes: [
    { rowKey: 1, columnId: 'qty', text: 'Check the count' },
    { rowKey: 3, columnId: 'qty', text: 'Reorder soon' },
  ],
  // Normal tooltips use the default settings (120ms, mouse); only notes appear slowly and stay longer.
  cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 },
};
let say = () => { };
export function setup(api, log) {
  say = log;
  const off = api.on('tooltipShown', (e) => say(`Tooltip (${e.target}) shown`));
  return off;
}
export const actions = {
  // So notes can be seen on touch too, focus the note cell to show it (with trigger: 'both' it also appears on focus).
  show: (api) => {
    api.focusCell(1, 'qty');
    say('Focused the quantity cell of row 1: the note appears after showDelay');
  },
  fast: (api) => {
    api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
    say('Notes: instant show and hide');
  },
  slow: (api) => {
    api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
    say('Notes: show after 600ms, stay 800ms');
  },
  inherit: (api) => {
    api.setOptions({ cellNoteOptions: {} });
    say('Notes follow the normal tooltip settings again');
  },
};