마우스를 올리면 나오는 말풍선Tooltips that appear on hover
헤더에는 설명 말풍선을, 셀에는 컬럼마다 다른 내용의 말풍선을 달 수 있어요. 어떤 컬럼은 말풍선을 빼고, 뜨는 시간도 정할 수 있어요.Headers can carry a help tooltip and cells can show different content per column, or none at all. You can also set how soon it appears.
코드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">
<select aria-label="셀 말풍선" id="cells">
<option value="on" selected>켜기</option>
<option value="off">끄기</option>
</select>
<select aria-label=""상품" 셀 말풍선 내용" id="productTip">
<option value="color" selected>같은 줄의 색상</option>
<option value="value">자기 값</option>
</select>
<select aria-label="나오는 시간" id="delay">
<option value="0">바로</option>
<option value="120" selected>기본 (0.12초)</option>
<option value="800">천천히 (0.8초)</option>
</select>
</div>
<div id="grid" style="height: 300px"></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('cells').addEventListener('change', (event) => actions.cells(api, event.target.value));
document.getElementById('productTip').addEventListener('change', (event) => actions.productTip(api, event.target.value));
document.getElementById('delay').addEventListener('change', (event) => actions.delay(api, event.target.value));// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
const customers = ['김서연', '이준호', '박민지', '최도윤', '정하은', '강지후'];
const products = ['무선 이어폰', '노트북 14형', '스마트워치', '태블릿 11형', '보조배터리'];
const colors = ['블랙', '화이트', '실버', '네이비', '핑크'];
const memos = [
'오전 중 배송 요청. 경비실에 맡겨 주세요.',
'선물 포장 필요. 카드에 "생일 축하해요" 문구를 넣어 주세요.',
'',
'회사 주소로 발송. 세금계산서는 다음 달 초에 발행해 주세요.',
'교환 이력 있음. 동일 색상으로 다시 보내기.',
'부재 시 문 앞에 두고 문자 남겨 주세요.',
];
const rows = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59000 + ((i * 7) % 9) * 30000,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const won = (value) => `${Number(value).toLocaleString('ko-KR')}원`;
let on = true;
let productTip = 'color';
// 컬럼의 tooltip 옵션이 셀 말풍선을 정해요.
// - 고객: tooltip을 안 줬어요 → 말풍선 없음.
// - 상품: 함수를 줬어요 → 같은 줄의 "색상"(또는 자기 값)을 보여 줘요.
// - 메모: true → 셀에 보이는 글 전체. 칸이 좁아 잘리는 글을 읽을 수 있게요.
// 헤더 말풍선은 headerTooltip이고, 셀 말풍선과 같은 모양이에요.
const columns = () => [
{ id: 'customer', title: '고객', width: 90 },
{
id: 'product',
title: '상품',
width: 130,
headerTooltip: L('상품 칸에 마우스를 올리면\n선택한 내용이 말풍선으로 나와요.', 'Hover a product cell\nand the selected content shows in a tooltip.'),
...(on ? { tooltip: (row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: '가격',
kind: 'number',
width: 130, // 가장 긴 값(299,000원)이 좁은 화면에서도 말줄임 없이 들어가요.
align: 'end',
formatValue: won,
headerTooltip: L('부가세 포함 금액이에요.', 'The amount includes VAT.'),
},
{ id: 'quantity', title: '수량', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: '메모', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // 마우스를 올리고 말풍선이 나오기까지 기다리는 시간(ms). 기본 120.
};
export const actions = {
cells: (api, value) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api, value) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api, value) => api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};<!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">
<select aria-label="셀 말풍선" id="cells">
<option value="on" selected>켜기</option>
<option value="off">끄기</option>
</select>
<select aria-label=""상품" 셀 말풍선 내용" id="productTip">
<option value="color" selected>같은 줄의 색상</option>
<option value="value">자기 값</option>
</select>
<select aria-label="나오는 시간" id="delay">
<option value="0">바로</option>
<option value="120" selected>기본 (0.12초)</option>
<option value="800">천천히 (0.8초)</option>
</select>
</div>
<div id="grid" style="height: 300px"></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 customers = ['김서연', '이준호', '박민지', '최도윤', '정하은', '강지후'];
const products = ['무선 이어폰', '노트북 14형', '스마트워치', '태블릿 11형', '보조배터리'];
const colors = ['블랙', '화이트', '실버', '네이비', '핑크'];
const memos = [
'오전 중 배송 요청. 경비실에 맡겨 주세요.',
'선물 포장 필요. 카드에 "생일 축하해요" 문구를 넣어 주세요.',
'',
'회사 주소로 발송. 세금계산서는 다음 달 초에 발행해 주세요.',
'교환 이력 있음. 동일 색상으로 다시 보내기.',
'부재 시 문 앞에 두고 문자 남겨 주세요.',
];
const rows = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59000 + ((i * 7) % 9) * 30000,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const won = (value) => `${Number(value).toLocaleString('ko-KR')}원`;
let on = true;
let productTip = 'color';
// 컬럼의 tooltip 옵션이 셀 말풍선을 정해요.
// - 고객: tooltip을 안 줬어요 → 말풍선 없음.
// - 상품: 함수를 줬어요 → 같은 줄의 "색상"(또는 자기 값)을 보여 줘요.
// - 메모: true → 셀에 보이는 글 전체. 칸이 좁아 잘리는 글을 읽을 수 있게요.
// 헤더 말풍선은 headerTooltip이고, 셀 말풍선과 같은 모양이에요.
const columns = () => [
{ id: 'customer', title: '고객', width: 90 },
{
id: 'product',
title: '상품',
width: 130,
headerTooltip: L('상품 칸에 마우스를 올리면\n선택한 내용이 말풍선으로 나와요.', 'Hover a product cell\nand the selected content shows in a tooltip.'),
...(on ? { tooltip: (row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: '가격',
kind: 'number',
width: 130, // 가장 긴 값(299,000원)이 좁은 화면에서도 말줄임 없이 들어가요.
align: 'end',
formatValue: won,
headerTooltip: L('부가세 포함 금액이에요.', 'The amount includes VAT.'),
},
{ id: 'quantity', title: '수량', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: '메모', width: 200, ...(on ? { tooltip: true } : {}) },
];
const options = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // 마우스를 올리고 말풍선이 나오기까지 기다리는 시간(ms). 기본 120.
};
const actions = {
cells: (api, value) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api, value) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api, value) => api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};
options.ariaLabel = "마우스를 올리면 나오는 말풍선";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('cells').addEventListener('change', (event) => actions.cells(api, event.target.value));
document.getElementById('productTip').addEventListener('change', (event) => actions.productTip(api, event.target.value));
document.getElementById('delay').addEventListener('change', (event) => actions.delay(api, event.target.value));
</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">
<select
aria-label="셀 말풍선"
disabled={!api}
onChange={(event) => api && actions.cells(api, event.target.value)}
>
<option value="on">켜기</option>
<option value="off">끄기</option>
</select>
<select defaultValue="on"
aria-label=""상품" 셀 말풍선 내용"
disabled={!api}
onChange={(event) => api && actions.productTip(api, event.target.value)}
>
<option value="color">같은 줄의 색상</option>
<option value="value">자기 값</option>
</select>
<select defaultValue="color"
aria-label="나오는 시간"
disabled={!api}
onChange={(event) => api && actions.delay(api, event.target.value)}
>
<option value="0">바로</option>
<option value="120">기본 (0.12초)</option>
<option value="800">천천히 (0.8초)</option>
</select>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, 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;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = ['김서연', '이준호', '박민지', '최도윤', '정하은', '강지후'];
const products = ['무선 이어폰', '노트북 14형', '스마트워치', '태블릿 11형', '보조배터리'];
const colors = ['블랙', '화이트', '실버', '네이비', '핑크'];
const memos = [
'오전 중 배송 요청. 경비실에 맡겨 주세요.',
'선물 포장 필요. 카드에 "생일 축하해요" 문구를 넣어 주세요.',
'',
'회사 주소로 발송. 세금계산서는 다음 달 초에 발행해 주세요.',
'교환 이력 있음. 동일 색상으로 다시 보내기.',
'부재 시 문 앞에 두고 문자 남겨 주세요.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59000 + ((i * 7) % 9) * 30000,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const won = (value: unknown) => `${Number(value).toLocaleString('ko-KR')}원`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// 컬럼의 tooltip 옵션이 셀 말풍선을 정해요.
// - 고객: tooltip을 안 줬어요 → 말풍선 없음.
// - 상품: 함수를 줬어요 → 같은 줄의 "색상"(또는 자기 값)을 보여 줘요.
// - 메모: true → 셀에 보이는 글 전체. 칸이 좁아 잘리는 글을 읽을 수 있게요.
// 헤더 말풍선은 headerTooltip이고, 셀 말풍선과 같은 모양이에요.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: '고객', width: 90 },
{
id: 'product',
title: '상품',
width: 130,
headerTooltip: L(
'상품 칸에 마우스를 올리면\n선택한 내용이 말풍선으로 나와요.',
'Hover a product cell\nand the selected content shows in a tooltip.',
),
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: '가격',
kind: 'number',
width: 130, // 가장 긴 값(299,000원)이 좁은 화면에서도 말줄임 없이 들어가요.
align: 'end',
formatValue: won,
headerTooltip: L('부가세 포함 금액이에요.', 'The amount includes VAT.'),
},
{ id: 'quantity', title: '수량', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: '메모', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // 마우스를 올리고 말풍선이 나오기까지 기다리는 시간(ms). 기본 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};버튼을 누르면 이 예제의 코드가 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">
<select
aria-label="셀 말풍선"
:disabled="!api"
@change="api && actions.cells(api, ($event.target as HTMLSelectElement).value)"
>
<option value="on" selected>켜기</option>
<option value="off">끄기</option>
</select>
<select
aria-label=""상품" 셀 말풍선 내용"
:disabled="!api"
@change="api && actions.productTip(api, ($event.target as HTMLSelectElement).value)"
>
<option value="color" selected>같은 줄의 색상</option>
<option value="value">자기 값</option>
</select>
<select
aria-label="나오는 시간"
:disabled="!api"
@change="api && actions.delay(api, ($event.target as HTMLSelectElement).value)"
>
<option value="0">바로</option>
<option value="120" selected>기본 (0.12초)</option>
<option value="800">천천히 (0.8초)</option>
</select>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { ColumnDef, GridApi, 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;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = ['김서연', '이준호', '박민지', '최도윤', '정하은', '강지후'];
const products = ['무선 이어폰', '노트북 14형', '스마트워치', '태블릿 11형', '보조배터리'];
const colors = ['블랙', '화이트', '실버', '네이비', '핑크'];
const memos = [
'오전 중 배송 요청. 경비실에 맡겨 주세요.',
'선물 포장 필요. 카드에 "생일 축하해요" 문구를 넣어 주세요.',
'',
'회사 주소로 발송. 세금계산서는 다음 달 초에 발행해 주세요.',
'교환 이력 있음. 동일 색상으로 다시 보내기.',
'부재 시 문 앞에 두고 문자 남겨 주세요.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59000 + ((i * 7) % 9) * 30000,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const won = (value: unknown) => `${Number(value).toLocaleString('ko-KR')}원`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// 컬럼의 tooltip 옵션이 셀 말풍선을 정해요.
// - 고객: tooltip을 안 줬어요 → 말풍선 없음.
// - 상품: 함수를 줬어요 → 같은 줄의 "색상"(또는 자기 값)을 보여 줘요.
// - 메모: true → 셀에 보이는 글 전체. 칸이 좁아 잘리는 글을 읽을 수 있게요.
// 헤더 말풍선은 headerTooltip이고, 셀 말풍선과 같은 모양이에요.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: '고객', width: 90 },
{
id: 'product',
title: '상품',
width: 130,
headerTooltip: L(
'상품 칸에 마우스를 올리면\n선택한 내용이 말풍선으로 나와요.',
'Hover a product cell\nand the selected content shows in a tooltip.',
),
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: '가격',
kind: 'number',
width: 130, // 가장 긴 값(299,000원)이 좁은 화면에서도 말줄임 없이 들어가요.
align: 'end',
formatValue: won,
headerTooltip: L('부가세 포함 금액이에요.', 'The amount includes VAT.'),
},
{ id: 'quantity', title: '수량', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: '메모', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // 마우스를 올리고 말풍선이 나오기까지 기다리는 시간(ms). 기본 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};버튼을 누르면 이 예제의 코드가 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">
<select
aria-label="셀 말풍선"
[disabled]="!api"
(change)="api && actions.cells(api, $any($event.target).value)"
>
<option value="on" selected>켜기</option>
<option value="off">끄기</option>
</select>
<select
aria-label=""상품" 셀 말풍선 내용"
[disabled]="!api"
(change)="api && actions.productTip(api, $any($event.target).value)"
>
<option value="color" selected>같은 줄의 색상</option>
<option value="value">자기 값</option>
</select>
<select
aria-label="나오는 시간"
[disabled]="!api"
(change)="api && actions.delay(api, $any($event.target).value)"
>
<option value="0">바로</option>
<option value="120" selected>기본 (0.12초)</option>
<option value="800">천천히 (0.8초)</option>
</select>
</div>
<mx-grid style="height: 300px" [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 { ColumnDef, GridApi, 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;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = ['김서연', '이준호', '박민지', '최도윤', '정하은', '강지후'];
const products = ['무선 이어폰', '노트북 14형', '스마트워치', '태블릿 11형', '보조배터리'];
const colors = ['블랙', '화이트', '실버', '네이비', '핑크'];
const memos = [
'오전 중 배송 요청. 경비실에 맡겨 주세요.',
'선물 포장 필요. 카드에 "생일 축하해요" 문구를 넣어 주세요.',
'',
'회사 주소로 발송. 세금계산서는 다음 달 초에 발행해 주세요.',
'교환 이력 있음. 동일 색상으로 다시 보내기.',
'부재 시 문 앞에 두고 문자 남겨 주세요.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59000 + ((i * 7) % 9) * 30000,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const won = (value: unknown) => `${Number(value).toLocaleString('ko-KR')}원`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// 컬럼의 tooltip 옵션이 셀 말풍선을 정해요.
// - 고객: tooltip을 안 줬어요 → 말풍선 없음.
// - 상품: 함수를 줬어요 → 같은 줄의 "색상"(또는 자기 값)을 보여 줘요.
// - 메모: true → 셀에 보이는 글 전체. 칸이 좁아 잘리는 글을 읽을 수 있게요.
// 헤더 말풍선은 headerTooltip이고, 셀 말풍선과 같은 모양이에요.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: '고객', width: 90 },
{
id: 'product',
title: '상품',
width: 130,
headerTooltip: L(
'상품 칸에 마우스를 올리면\n선택한 내용이 말풍선으로 나와요.',
'Hover a product cell\nand the selected content shows in a tooltip.',
),
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: '가격',
kind: 'number',
width: 130, // 가장 긴 값(299,000원)이 좁은 화면에서도 말줄임 없이 들어가요.
align: 'end',
formatValue: won,
headerTooltip: L('부가세 포함 금액이에요.', 'The amount includes VAT.'),
},
{ id: 'quantity', title: '수량', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: '메모', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // 마우스를 올리고 말풍선이 나오기까지 기다리는 시간(ms). 기본 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Cell tooltips" id="cells">
<option value="on" selected>On</option>
<option value="off">Off</option>
</select>
<select aria-label=""Product" cell tooltip" id="productTip">
<option value="color" selected>Color of the row</option>
<option value="value">Its own value</option>
</select>
<select aria-label="Delay" id="delay">
<option value="0">Instant</option>
<option value="120" selected>Default (0.12 s)</option>
<option value="800">Slow (0.8 s)</option>
</select>
</div>
<div id="grid" style="height: 300px"></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('cells').addEventListener('change', (event) => actions.cells(api, event.target.value));
document.getElementById('productTip').addEventListener('change', (event) => actions.productTip(api, event.target.value));
document.getElementById('delay').addEventListener('change', (event) => actions.delay(api, event.target.value));const customers = [
'Emma Stone',
'Liam Carter',
'Mia Foster',
'Noah Brooks',
'Ava Morgan',
'Lucas Bell',
];
const products = ['Wireless Earbuds', 'Laptop 14"', 'Smartwatch', 'Tablet 11"', 'Power Bank'];
const colors = ['Black', 'White', 'Silver', 'Navy', 'Pink'];
const memos = [
'Please deliver in the morning and leave it with the front desk.',
'Gift wrapping needed. Put "Happy birthday" on the card.',
'',
'Ship to the office address. Please issue the tax invoice early next month.',
'Has an exchange history. Send again in the same color.',
'If nobody is home, leave it at the door and send a text.',
];
const rows = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59 + ((i * 7) % 9) * 30,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const usd = (value) => `$${Number(value).toLocaleString('en-US')}`;
let on = true;
let productTip = 'color';
// The column's tooltip option decides the cell tooltip.
// - Customer: no tooltip given -> no tooltip.
// - Product: a function is given -> shows the "color" of the same row (or its own value).
// - Memo: true -> the whole text shown in the cell, so text cut off by a narrow cell can be read.
// The header tooltip is headerTooltip and looks the same as a cell tooltip.
const columns = () => [
{ id: 'customer', title: 'Customer', width: 90 },
{
id: 'product',
title: 'Product',
width: 130,
headerTooltip: 'Hover a product cell\nand the selected content shows in a tooltip.',
...(on ? { tooltip: (row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: 'Price',
kind: 'number',
width: 130, // The longest value ($299) fits without an ellipsis even on a narrow screen.
align: 'end',
formatValue: usd,
headerTooltip: 'The amount includes VAT.',
},
{ id: 'quantity', title: 'Qty', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: 'Memo', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // Time (ms) to wait after hovering before the tooltip appears. Default 120.
};
export const actions = {
cells: (api, value) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api, value) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api, value) => api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tooltips that appear on hover</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Cell tooltips" id="cells">
<option value="on" selected>On</option>
<option value="off">Off</option>
</select>
<select aria-label=""Product" cell tooltip" id="productTip">
<option value="color" selected>Color of the row</option>
<option value="value">Its own value</option>
</select>
<select aria-label="Delay" id="delay">
<option value="0">Instant</option>
<option value="120" selected>Default (0.12 s)</option>
<option value="800">Slow (0.8 s)</option>
</select>
</div>
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const customers = [
'Emma Stone',
'Liam Carter',
'Mia Foster',
'Noah Brooks',
'Ava Morgan',
'Lucas Bell',
];
const products = ['Wireless Earbuds', 'Laptop 14"', 'Smartwatch', 'Tablet 11"', 'Power Bank'];
const colors = ['Black', 'White', 'Silver', 'Navy', 'Pink'];
const memos = [
'Please deliver in the morning and leave it with the front desk.',
'Gift wrapping needed. Put "Happy birthday" on the card.',
'',
'Ship to the office address. Please issue the tax invoice early next month.',
'Has an exchange history. Send again in the same color.',
'If nobody is home, leave it at the door and send a text.',
];
const rows = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59 + ((i * 7) % 9) * 30,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const usd = (value) => `$${Number(value).toLocaleString('en-US')}`;
let on = true;
let productTip = 'color';
// The column's tooltip option decides the cell tooltip.
// - Customer: no tooltip given -> no tooltip.
// - Product: a function is given -> shows the "color" of the same row (or its own value).
// - Memo: true -> the whole text shown in the cell, so text cut off by a narrow cell can be read.
// The header tooltip is headerTooltip and looks the same as a cell tooltip.
const columns = () => [
{ id: 'customer', title: 'Customer', width: 90 },
{
id: 'product',
title: 'Product',
width: 130,
headerTooltip: 'Hover a product cell\nand the selected content shows in a tooltip.',
...(on ? { tooltip: (row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: 'Price',
kind: 'number',
width: 130, // The longest value ($299) fits without an ellipsis even on a narrow screen.
align: 'end',
formatValue: usd,
headerTooltip: 'The amount includes VAT.',
},
{ id: 'quantity', title: 'Qty', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: 'Memo', width: 200, ...(on ? { tooltip: true } : {}) },
];
const options = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // Time (ms) to wait after hovering before the tooltip appears. Default 120.
};
const actions = {
cells: (api, value) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api, value) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api, value) => api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};
options.ariaLabel = "Tooltips that appear on hover";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('cells').addEventListener('change', (event) => actions.cells(api, event.target.value));
document.getElementById('productTip').addEventListener('change', (event) => actions.productTip(api, event.target.value));
document.getElementById('delay').addEventListener('change', (event) => actions.delay(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 { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<select
aria-label="Cell tooltips"
disabled={!api}
onChange={(event) => api && actions.cells(api, event.target.value)}
>
<option value="on">On</option>
<option value="off">Off</option>
</select>
<select defaultValue="on"
aria-label=""Product" cell tooltip"
disabled={!api}
onChange={(event) => api && actions.productTip(api, event.target.value)}
>
<option value="color">Color of the row</option>
<option value="value">Its own value</option>
</select>
<select defaultValue="color"
aria-label="Delay"
disabled={!api}
onChange={(event) => api && actions.delay(api, event.target.value)}
>
<option value="0">Instant</option>
<option value="120">Default (0.12 s)</option>
<option value="800">Slow (0.8 s)</option>
</select>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = [
'Emma Stone',
'Liam Carter',
'Mia Foster',
'Noah Brooks',
'Ava Morgan',
'Lucas Bell',
];
const products = ['Wireless Earbuds', 'Laptop 14"', 'Smartwatch', 'Tablet 11"', 'Power Bank'];
const colors = ['Black', 'White', 'Silver', 'Navy', 'Pink'];
const memos = [
'Please deliver in the morning and leave it with the front desk.',
'Gift wrapping needed. Put "Happy birthday" on the card.',
'',
'Ship to the office address. Please issue the tax invoice early next month.',
'Has an exchange history. Send again in the same color.',
'If nobody is home, leave it at the door and send a text.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59 + ((i * 7) % 9) * 30,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const usd = (value: unknown) => `$${Number(value).toLocaleString('en-US')}`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// The column's tooltip option decides the cell tooltip.
// - Customer: no tooltip given -> no tooltip.
// - Product: a function is given -> shows the "color" of the same row (or its own value).
// - Memo: true -> the whole text shown in the cell, so text cut off by a narrow cell can be read.
// The header tooltip is headerTooltip and looks the same as a cell tooltip.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: 'Customer', width: 90 },
{
id: 'product',
title: 'Product',
width: 130,
headerTooltip: 'Hover a product cell\nand the selected content shows in a tooltip.',
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: 'Price',
kind: 'number',
width: 130, // The longest value ($299) fits without an ellipsis even on a narrow screen.
align: 'end',
formatValue: usd,
headerTooltip: 'The amount includes VAT.',
},
{ id: 'quantity', title: 'Qty', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: 'Memo', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // Time (ms) to wait after hovering before the tooltip appears. Default 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};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">
<select
aria-label="Cell tooltips"
:disabled="!api"
@change="api && actions.cells(api, ($event.target as HTMLSelectElement).value)"
>
<option value="on" selected>On</option>
<option value="off">Off</option>
</select>
<select
aria-label=""Product" cell tooltip"
:disabled="!api"
@change="api && actions.productTip(api, ($event.target as HTMLSelectElement).value)"
>
<option value="color" selected>Color of the row</option>
<option value="value">Its own value</option>
</select>
<select
aria-label="Delay"
:disabled="!api"
@change="api && actions.delay(api, ($event.target as HTMLSelectElement).value)"
>
<option value="0">Instant</option>
<option value="120" selected>Default (0.12 s)</option>
<option value="800">Slow (0.8 s)</option>
</select>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { ColumnDef, GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = [
'Emma Stone',
'Liam Carter',
'Mia Foster',
'Noah Brooks',
'Ava Morgan',
'Lucas Bell',
];
const products = ['Wireless Earbuds', 'Laptop 14"', 'Smartwatch', 'Tablet 11"', 'Power Bank'];
const colors = ['Black', 'White', 'Silver', 'Navy', 'Pink'];
const memos = [
'Please deliver in the morning and leave it with the front desk.',
'Gift wrapping needed. Put "Happy birthday" on the card.',
'',
'Ship to the office address. Please issue the tax invoice early next month.',
'Has an exchange history. Send again in the same color.',
'If nobody is home, leave it at the door and send a text.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59 + ((i * 7) % 9) * 30,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const usd = (value: unknown) => `$${Number(value).toLocaleString('en-US')}`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// The column's tooltip option decides the cell tooltip.
// - Customer: no tooltip given -> no tooltip.
// - Product: a function is given -> shows the "color" of the same row (or its own value).
// - Memo: true -> the whole text shown in the cell, so text cut off by a narrow cell can be read.
// The header tooltip is headerTooltip and looks the same as a cell tooltip.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: 'Customer', width: 90 },
{
id: 'product',
title: 'Product',
width: 130,
headerTooltip: 'Hover a product cell\nand the selected content shows in a tooltip.',
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: 'Price',
kind: 'number',
width: 130, // The longest value ($299) fits without an ellipsis even on a narrow screen.
align: 'end',
formatValue: usd,
headerTooltip: 'The amount includes VAT.',
},
{ id: 'quantity', title: 'Qty', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: 'Memo', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // Time (ms) to wait after hovering before the tooltip appears. Default 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};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">
<select
aria-label="Cell tooltips"
[disabled]="!api"
(change)="api && actions.cells(api, $any($event.target).value)"
>
<option value="on" selected>On</option>
<option value="off">Off</option>
</select>
<select
aria-label=""Product" cell tooltip"
[disabled]="!api"
(change)="api && actions.productTip(api, $any($event.target).value)"
>
<option value="color" selected>Color of the row</option>
<option value="value">Its own value</option>
</select>
<select
aria-label="Delay"
[disabled]="!api"
(change)="api && actions.delay(api, $any($event.target).value)"
>
<option value="0">Instant</option>
<option value="120" selected>Default (0.12 s)</option>
<option value="800">Slow (0.8 s)</option>
</select>
</div>
<mx-grid style="height: 300px" [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 { ColumnDef, GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
customer: string;
product: string;
color: string;
price: number;
quantity: number;
memo: string;
}
const customers = [
'Emma Stone',
'Liam Carter',
'Mia Foster',
'Noah Brooks',
'Ava Morgan',
'Lucas Bell',
];
const products = ['Wireless Earbuds', 'Laptop 14"', 'Smartwatch', 'Tablet 11"', 'Power Bank'];
const colors = ['Black', 'White', 'Silver', 'Navy', 'Pink'];
const memos = [
'Please deliver in the morning and leave it with the front desk.',
'Gift wrapping needed. Put "Happy birthday" on the card.',
'',
'Ship to the office address. Please issue the tax invoice early next month.',
'Has an exchange history. Send again in the same color.',
'If nobody is home, leave it at the door and send a text.',
];
const rows: Row[] = Array.from({ length: 6 }, (_, i) => ({
id: i + 1,
customer: customers[i],
product: products[(i * 2) % products.length],
color: colors[(i * 3) % colors.length],
price: 59 + ((i * 7) % 9) * 30,
quantity: 1 + ((i * 5) % 6),
memo: memos[i],
}));
const usd = (value: unknown) => `$${Number(value).toLocaleString('en-US')}`;
type Content = 'value' | 'color';
let on = true;
let productTip: Content = 'color';
// The column's tooltip option decides the cell tooltip.
// - Customer: no tooltip given -> no tooltip.
// - Product: a function is given -> shows the "color" of the same row (or its own value).
// - Memo: true -> the whole text shown in the cell, so text cut off by a narrow cell can be read.
// The header tooltip is headerTooltip and looks the same as a cell tooltip.
const columns = (): ColumnDef<Row>[] => [
{ id: 'customer', title: 'Customer', width: 90 },
{
id: 'product',
title: 'Product',
width: 130,
headerTooltip: 'Hover a product cell\nand the selected content shows in a tooltip.',
...(on ? { tooltip: (row: Row) => (productTip === 'color' ? row.color : row.product) } : {}),
},
{
id: 'price',
title: 'Price',
kind: 'number',
width: 130, // The longest value ($299) fits without an ellipsis even on a narrow screen.
align: 'end',
formatValue: usd,
headerTooltip: 'The amount includes VAT.',
},
{ id: 'quantity', title: 'Qty', kind: 'number', width: 70, align: 'end' },
{ id: 'memo', title: 'Memo', width: 200, ...(on ? { tooltip: true } : {}) },
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
tooltipDelay: 120, // Time (ms) to wait after hovering before the tooltip appears. Default 120.
};
export const actions = {
cells: (api: GridApi<Row>, value?: string) => {
on = value !== 'off';
api.setColumns(columns());
},
productTip: (api: GridApi<Row>, value?: string) => {
productTip = value === 'value' ? 'value' : 'color';
api.setColumns(columns());
},
delay: (api: GridApi<Row>, value?: string) =>
api.setOptions({ tooltipDelay: Number(value ?? 120) }),
};