메모 말풍선만 따로 조정하기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.
코드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="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>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));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',
});
},
};<!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="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>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const en = document.documentElement.dataset.lang === 'en';
const names = en ? ['Pen', 'Notebook', 'Stapler', 'Tape'] : ['펜', '노트', '스테이플러', '테이프'];
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 = () => { };
function setup(api, log) {
say = log;
const off = api.on('tooltipShown', (e) => say({ ko: `말풍선(${e.target}) 표시`, en: `Tooltip (${e.target}) shown` }));
return off;
}
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',
});
},
};
options.ariaLabel = "메모 말풍선만 따로 조정하기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
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));
</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, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.show(api)}
>메모 보기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.fast(api)}
>메모 바로 보이기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.slow(api)}
>메모 천천히</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.inherit(api)}
>기본 따르기</button>
</div>
<Grid style={{ height: 200 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const en = document.documentElement.dataset.lang === 'en';
const names = en ? ['Pen', 'Notebook', 'Stapler', 'Tape'] : ['펜', '노트', '스테이플러', '테이프'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say({
ko: '1번 행 수량 칸에 포커스: 지연(showDelay) 뒤 메모가 나타나요',
en: 'Focused the quantity cell of row 1: the note appears after showDelay',
});
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say({ ko: '메모: 바로 나타나고 바로 사라져요', en: 'Notes: instant show and hide' });
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say({ ko: '메모: 600ms 뒤 나타나고 800ms 남아요', en: 'Notes: show after 600ms, stay 800ms' });
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say({
ko: '메모도 일반 말풍선 설정을 따라요',
en: 'Notes follow the normal tooltip settings again',
});
},
};버튼을 누르면 이 예제의 코드가 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, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.show(api)">메모 보기</button>
<button type="button" :disabled="!api" @click="api && actions.fast(api)">메모 바로 보이기</button>
<button type="button" :disabled="!api" @click="api && actions.slow(api)">메모 천천히</button>
<button type="button" :disabled="!api" @click="api && actions.inherit(api)">기본 따르기</button>
</div>
<Grid style="height: 200px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const en = document.documentElement.dataset.lang === 'en';
const names = en ? ['Pen', 'Notebook', 'Stapler', 'Tape'] : ['펜', '노트', '스테이플러', '테이프'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say({
ko: '1번 행 수량 칸에 포커스: 지연(showDelay) 뒤 메모가 나타나요',
en: 'Focused the quantity cell of row 1: the note appears after showDelay',
});
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say({ ko: '메모: 바로 나타나고 바로 사라져요', en: 'Notes: instant show and hide' });
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say({ ko: '메모: 600ms 뒤 나타나고 800ms 남아요', en: 'Notes: show after 600ms, stay 800ms' });
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say({
ko: '메모도 일반 말풍선 설정을 따라요',
en: 'Notes follow the normal tooltip settings again',
});
},
};버튼을 누르면 이 예제의 코드가 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.show(api)"
>메모 보기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.fast(api)"
>메모 바로 보이기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.slow(api)"
>메모 천천히</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.inherit(api)"
>기본 따르기</button>
</div>
<mx-grid style="height: 200px" [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, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const en = document.documentElement.dataset.lang === 'en';
const names = en ? ['Pen', 'Notebook', 'Stapler', 'Tape'] : ['펜', '노트', '스테이플러', '테이프'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say({
ko: '1번 행 수량 칸에 포커스: 지연(showDelay) 뒤 메모가 나타나요',
en: 'Focused the quantity cell of row 1: the note appears after showDelay',
});
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say({ ko: '메모: 바로 나타나고 바로 사라져요', en: 'Notes: instant show and hide' });
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say({ ko: '메모: 600ms 뒤 나타나고 800ms 남아요', en: 'Notes: show after 600ms, stay 800ms' });
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say({
ko: '메모도 일반 말풍선 설정을 따라요',
en: 'Notes follow the normal tooltip settings again',
});
},
};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="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>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));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');
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tune only the note tooltip</title>
</head>
<body>
<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>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['Pen', 'Notebook', 'Stapler', 'Tape'];
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 = () => { };
function setup(api, log) {
say = log;
const off = api.on('tooltipShown', (e) => say(`Tooltip (${e.target}) shown`));
return off;
}
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');
},
};
options.ariaLabel = "Tune only the note tooltip";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
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));
</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, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.show(api)}
>Show note</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.fast(api)}
>Instant notes</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.slow(api)}
>Slow notes</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.inherit(api)}
>Follow defaults</button>
</div>
<Grid style={{ height: 200 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const names = ['Pen', 'Notebook', 'Stapler', 'Tape'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say('Focused the quantity cell of row 1: the note appears after showDelay');
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say('Notes: instant show and hide');
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say('Notes: show after 600ms, stay 800ms');
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say('Notes follow the normal tooltip settings again');
},
};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, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.show(api)">Show note</button>
<button type="button" :disabled="!api" @click="api && actions.fast(api)">Instant notes</button>
<button type="button" :disabled="!api" @click="api && actions.slow(api)">Slow notes</button>
<button type="button" :disabled="!api" @click="api && actions.inherit(api)">Follow defaults</button>
</div>
<Grid style="height: 200px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const names = ['Pen', 'Notebook', 'Stapler', 'Tape'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say('Focused the quantity cell of row 1: the note appears after showDelay');
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say('Notes: instant show and hide');
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say('Notes: show after 600ms, stay 800ms');
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say('Notes follow the normal tooltip settings again');
},
};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.show(api)"
>Show note</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.fast(api)"
>Instant notes</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.slow(api)"
>Slow notes</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.inherit(api)"
>Follow defaults</button>
</div>
<mx-grid style="height: 200px" [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, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
qty: number;
}
const names = ['Pen', 'Notebook', 'Stapler', 'Tape'];
export const options: GridOptions<Row> = {
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: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
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: GridApi<Row>) => {
api.focusCell(1, 'qty');
say('Focused the quantity cell of row 1: the note appears after showDelay');
},
fast: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'hover', showDelay: 0, hideDelay: 0 } });
say('Notes: instant show and hide');
},
slow: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: { trigger: 'both', showDelay: 600, hideDelay: 800 } });
say('Notes: show after 600ms, stay 800ms');
},
inherit: (api: GridApi<Row>) => {
api.setOptions({ cellNoteOptions: {} });
say('Notes follow the normal tooltip settings again');
},
};