마우스를 올리면 행이 켜질까, 칸이 켜질까?Highlight the row, the cell, or nothing on hover
마우스를 올렸을 때 행 전체를 칠할지, 칸 하나만 칠할지, 아무것도 안 칠할지를 설정 하나로 정해요.One setting decides whether the mouse paints the whole row, a single cell, or nothing.
코드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="mode">
<option value="row" selected>행 전체 (기본)</option>
<option value="cell">칸 하나</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<div id="grid" style="height: 420px"></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('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));const regions = ['서울', '부산', '대구', '제주'];
const managers = ['김민준', '이서연', '박지호', '최유나', '정도윤'];
const products = ['무선 이어폰', '스마트 워치', '노트북 거치대', '보조배터리', '블루투스 스피커'];
const statuses = ['배송 준비', '배송 중', '배송 완료'];
// 지역(region) 칸은 같은 값끼리 세로로 합쳐 보여요(merge). 합쳐진 칸 위에서 마우스 올림이 어떻게 보이는지도 확인해 보세요.
export const options = {
columns: [
{ id: 'region', title: '지역', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: '담당자', width: 110 },
{ id: 'customer', title: '고객번호', width: 120 },
{ id: 'product', title: '상품', width: 160 },
{ id: 'status', title: '상태', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)],
manager: managers[(i * 3) % 5],
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5],
status: statuses[(i * 7) % 3],
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// hover 옵션 하나로 마우스를 올렸을 때 칠할 범위를 정해요.
// 'row' : 올라간 행 전체(기본값)
// 'cell' : 올라간 칸 하나
// 'none' : 칠하지 않음
export const actions = {
mode: (api, value) => api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};<!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="mode">
<option value="row" selected>행 전체 (기본)</option>
<option value="cell">칸 하나</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<div id="grid" style="height: 420px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const regions = ['서울', '부산', '대구', '제주'];
const managers = ['김민준', '이서연', '박지호', '최유나', '정도윤'];
const products = ['무선 이어폰', '스마트 워치', '노트북 거치대', '보조배터리', '블루투스 스피커'];
const statuses = ['배송 준비', '배송 중', '배송 완료'];
// 지역(region) 칸은 같은 값끼리 세로로 합쳐 보여요(merge). 합쳐진 칸 위에서 마우스 올림이 어떻게 보이는지도 확인해 보세요.
const options = {
columns: [
{ id: 'region', title: '지역', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: '담당자', width: 110 },
{ id: 'customer', title: '고객번호', width: 120 },
{ id: 'product', title: '상품', width: 160 },
{ id: 'status', title: '상태', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)],
manager: managers[(i * 3) % 5],
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5],
status: statuses[(i * 7) % 3],
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// hover 옵션 하나로 마우스를 올렸을 때 칠할 범위를 정해요.
// 'row' : 올라간 행 전체(기본값)
// 'cell' : 올라간 칸 하나
// 'none' : 칠하지 않음
const actions = {
mode: (api, value) => api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};
options.ariaLabel = "마우스를 올리면 행이 켜질까, 칸이 켜질까?";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('mode').addEventListener('change', (event) => actions.mode(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.mode(api, event.target.value)}
>
<option value="row">행 전체 (기본)</option>
<option value="cell">칸 하나</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<Grid style={{ height: 420 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['서울', '부산', '대구', '제주'];
const managers = ['김민준', '이서연', '박지호', '최유나', '정도윤'];
const products = ['무선 이어폰', '스마트 워치', '노트북 거치대', '보조배터리', '블루투스 스피커'];
const statuses = ['배송 준비', '배송 중', '배송 완료'];
// 지역(region) 칸은 같은 값끼리 세로로 합쳐 보여요(merge). 합쳐진 칸 위에서 마우스 올림이 어떻게 보이는지도 확인해 보세요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: '담당자', width: 110 },
{ id: 'customer', title: '고객번호', width: 120 },
{ id: 'product', title: '상품', width: 160 },
{ id: 'status', title: '상태', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// hover 옵션 하나로 마우스를 올렸을 때 칠할 범위를 정해요.
// 'row' : 올라간 행 전체(기본값)
// 'cell' : 올라간 칸 하나
// 'none' : 칠하지 않음
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};버튼을 누르면 이 예제의 코드가 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.mode(api, ($event.target as HTMLSelectElement).value)"
>
<option value="row" selected>행 전체 (기본)</option>
<option value="cell">칸 하나</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<Grid style="height: 420px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['서울', '부산', '대구', '제주'];
const managers = ['김민준', '이서연', '박지호', '최유나', '정도윤'];
const products = ['무선 이어폰', '스마트 워치', '노트북 거치대', '보조배터리', '블루투스 스피커'];
const statuses = ['배송 준비', '배송 중', '배송 완료'];
// 지역(region) 칸은 같은 값끼리 세로로 합쳐 보여요(merge). 합쳐진 칸 위에서 마우스 올림이 어떻게 보이는지도 확인해 보세요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: '담당자', width: 110 },
{ id: 'customer', title: '고객번호', width: 120 },
{ id: 'product', title: '상품', width: 160 },
{ id: 'status', title: '상태', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// hover 옵션 하나로 마우스를 올렸을 때 칠할 범위를 정해요.
// 'row' : 올라간 행 전체(기본값)
// 'cell' : 올라간 칸 하나
// 'none' : 칠하지 않음
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};버튼을 누르면 이 예제의 코드가 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.mode(api, $any($event.target).value)"
>
<option value="row" selected>행 전체 (기본)</option>
<option value="cell">칸 하나</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<mx-grid style="height: 420px" [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 { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['서울', '부산', '대구', '제주'];
const managers = ['김민준', '이서연', '박지호', '최유나', '정도윤'];
const products = ['무선 이어폰', '스마트 워치', '노트북 거치대', '보조배터리', '블루투스 스피커'];
const statuses = ['배송 준비', '배송 중', '배송 완료'];
// 지역(region) 칸은 같은 값끼리 세로로 합쳐 보여요(merge). 합쳐진 칸 위에서 마우스 올림이 어떻게 보이는지도 확인해 보세요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: '지역', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: '담당자', width: 110 },
{ id: 'customer', title: '고객번호', width: 120 },
{ id: 'product', title: '상품', width: 160 },
{ id: 'status', title: '상태', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// hover 옵션 하나로 마우스를 올렸을 때 칠할 범위를 정해요.
// 'row' : 올라간 행 전체(기본값)
// 'cell' : 올라간 칸 하나
// 'none' : 칠하지 않음
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};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="Hover range" id="mode">
<option value="row" selected>Whole row (default)</option>
<option value="cell">Single cell</option>
<option value="none">Nothing</option>
</select>
</div>
<div id="grid" style="height: 420px"></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('mode').addEventListener('change', (event) => actions.mode(api, event.target.value));const regions = ['Seoul', 'Busan', 'Daegu', 'Jeju'];
const managers = ['Liam Carter', 'Emma Stone', 'Noah Brooks', 'Olivia Reed', 'Ethan Hayes'];
const products = [
'Wireless Earbuds',
'Smart Watch',
'Laptop Stand',
'Power Bank',
'Bluetooth Speaker',
];
const statuses = ['Preparing', 'Shipping', 'Delivered'];
// The region cells merge vertically where values repeat (merge). Also check how hover looks over a merged cell.
export const options = {
columns: [
{ id: 'region', title: 'Region', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: 'Manager', width: 130 },
{ id: 'customer', title: 'Customer ID', width: 120 },
{ id: 'product', title: 'Product', width: 160 },
{ id: 'status', title: 'Status', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)],
manager: managers[(i * 3) % 5],
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5],
status: statuses[(i * 7) % 3],
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// A single hover option sets how much is painted when the mouse is over the grid.
// 'row' : the whole hovered row (default)
// 'cell' : the single hovered cell
// 'none' : paint nothing
export const actions = {
mode: (api, value) => api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Highlight the row, the cell, or nothing on hover</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Hover range" id="mode">
<option value="row" selected>Whole row (default)</option>
<option value="cell">Single cell</option>
<option value="none">Nothing</option>
</select>
</div>
<div id="grid" style="height: 420px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const regions = ['Seoul', 'Busan', 'Daegu', 'Jeju'];
const managers = ['Liam Carter', 'Emma Stone', 'Noah Brooks', 'Olivia Reed', 'Ethan Hayes'];
const products = [
'Wireless Earbuds',
'Smart Watch',
'Laptop Stand',
'Power Bank',
'Bluetooth Speaker',
];
const statuses = ['Preparing', 'Shipping', 'Delivered'];
// The region cells merge vertically where values repeat (merge). Also check how hover looks over a merged cell.
const options = {
columns: [
{ id: 'region', title: 'Region', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: 'Manager', width: 130 },
{ id: 'customer', title: 'Customer ID', width: 120 },
{ id: 'product', title: 'Product', width: 160 },
{ id: 'status', title: 'Status', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)],
manager: managers[(i * 3) % 5],
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5],
status: statuses[(i * 7) % 3],
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// A single hover option sets how much is painted when the mouse is over the grid.
// 'row' : the whole hovered row (default)
// 'cell' : the single hovered cell
// 'none' : paint nothing
const actions = {
mode: (api, value) => api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};
options.ariaLabel = "Highlight the row, the cell, or nothing on hover";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('mode').addEventListener('change', (event) => actions.mode(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="Hover range"
disabled={!api}
onChange={(event) => api && actions.mode(api, event.target.value)}
>
<option value="row">Whole row (default)</option>
<option value="cell">Single cell</option>
<option value="none">Nothing</option>
</select>
</div>
<Grid style={{ height: 420 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['Seoul', 'Busan', 'Daegu', 'Jeju'];
const managers = ['Liam Carter', 'Emma Stone', 'Noah Brooks', 'Olivia Reed', 'Ethan Hayes'];
const products = [
'Wireless Earbuds',
'Smart Watch',
'Laptop Stand',
'Power Bank',
'Bluetooth Speaker',
];
const statuses = ['Preparing', 'Shipping', 'Delivered'];
// The region cells merge vertically where values repeat (merge). Also check how hover looks over a merged cell.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: 'Manager', width: 130 },
{ id: 'customer', title: 'Customer ID', width: 120 },
{ id: 'product', title: 'Product', width: 160 },
{ id: 'status', title: 'Status', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// A single hover option sets how much is painted when the mouse is over the grid.
// 'row' : the whole hovered row (default)
// 'cell' : the single hovered cell
// 'none' : paint nothing
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};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="Hover range"
:disabled="!api"
@change="api && actions.mode(api, ($event.target as HTMLSelectElement).value)"
>
<option value="row" selected>Whole row (default)</option>
<option value="cell">Single cell</option>
<option value="none">Nothing</option>
</select>
</div>
<Grid style="height: 420px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['Seoul', 'Busan', 'Daegu', 'Jeju'];
const managers = ['Liam Carter', 'Emma Stone', 'Noah Brooks', 'Olivia Reed', 'Ethan Hayes'];
const products = [
'Wireless Earbuds',
'Smart Watch',
'Laptop Stand',
'Power Bank',
'Bluetooth Speaker',
];
const statuses = ['Preparing', 'Shipping', 'Delivered'];
// The region cells merge vertically where values repeat (merge). Also check how hover looks over a merged cell.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: 'Manager', width: 130 },
{ id: 'customer', title: 'Customer ID', width: 120 },
{ id: 'product', title: 'Product', width: 160 },
{ id: 'status', title: 'Status', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// A single hover option sets how much is painted when the mouse is over the grid.
// 'row' : the whole hovered row (default)
// 'cell' : the single hovered cell
// 'none' : paint nothing
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};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="Hover range"
[disabled]="!api"
(change)="api && actions.mode(api, $any($event.target).value)"
>
<option value="row" selected>Whole row (default)</option>
<option value="cell">Single cell</option>
<option value="none">Nothing</option>
</select>
</div>
<mx-grid style="height: 420px" [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 { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
region: string;
manager: string;
customer: string;
product: string;
status: string;
}
const regions = ['Seoul', 'Busan', 'Daegu', 'Jeju'];
const managers = ['Liam Carter', 'Emma Stone', 'Noah Brooks', 'Olivia Reed', 'Ethan Hayes'];
const products = [
'Wireless Earbuds',
'Smart Watch',
'Laptop Stand',
'Power Bank',
'Bluetooth Speaker',
];
const statuses = ['Preparing', 'Shipping', 'Delivered'];
// The region cells merge vertically where values repeat (merge). Also check how hover looks over a merged cell.
export const options: GridOptions<Row> = {
columns: [
{ id: 'region', title: 'Region', width: 90, merge: true, align: 'center' },
{ id: 'manager', title: 'Manager', width: 130 },
{ id: 'customer', title: 'Customer ID', width: 120 },
{ id: 'product', title: 'Product', width: 160 },
{ id: 'status', title: 'Status', width: 110 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
region: regions[Math.floor(i / 4)] as string,
manager: managers[(i * 3) % 5] as string,
customer: `C-${String(1000 + ((i * 137) % 900)).padStart(4, '0')}`,
product: products[(i * 2) % 5] as string,
status: statuses[(i * 7) % 3] as string,
})),
rowKey: 'id',
striped: false,
hover: 'row',
};
// A single hover option sets how much is painted when the mouse is over the grid.
// 'row' : the whole hovered row (default)
// 'cell' : the single hovered cell
// 'none' : paint nothing
export const actions = {
mode: (api: GridApi<Row>, value?: string) =>
api.setOptions({ hover: value === 'cell' || value === 'none' ? value : 'row' }),
};