마우스를 올리면 컬럼도 켜기Highlight the column on hover
hover 옵션에 'column'(세로 줄)과 'cross'(가로+세로 십자)를 더해 표를 읽기 쉽게 해요.Add 'column' and 'cross' to the hover option to light up the column or the row and column together.
코드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">행 (기본)</option>
<option value="column">컬럼</option>
<option value="cross" selected>십자 (행+컬럼)</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<div id="grid" style="height: 380px"></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 months = [
'1월',
'2월',
'3월',
'4월',
'5월',
'6월',
'7월',
'8월',
'9월',
'10월',
'11월',
'12월',
];
export const options = {
columns: [
{ id: 'month', title: '월', width: 80 },
{ id: 'seoul', title: '서울', width: 110, kind: 'number' },
{ id: 'busan', title: '부산', width: 110, kind: 'number' },
{ id: 'daegu', title: '대구', width: 110, kind: 'number' },
{ id: 'jeju', title: '제주', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api, value) => {
const modes = ['row', 'column', 'cross', 'none'];
api.setOptions({ hover: modes.find((m) => m === 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">행 (기본)</option>
<option value="column">컬럼</option>
<option value="cross" selected>십자 (행+컬럼)</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<div id="grid" style="height: 380px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const months = [
'1월',
'2월',
'3월',
'4월',
'5월',
'6월',
'7월',
'8월',
'9월',
'10월',
'11월',
'12월',
];
const options = {
columns: [
{ id: 'month', title: '월', width: 80 },
{ id: 'seoul', title: '서울', width: 110, kind: 'number' },
{ id: 'busan', title: '부산', width: 110, kind: 'number' },
{ id: 'daegu', title: '대구', width: 110, kind: 'number' },
{ id: 'jeju', title: '제주', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
const actions = {
mode: (api, value) => {
const modes = ['row', 'column', 'cross', 'none'];
api.setOptions({ hover: modes.find((m) => m === 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="column">컬럼</option>
<option value="cross">십자 (행+컬럼)</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<Grid style={{ height: 380 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = [
'1월',
'2월',
'3월',
'4월',
'5월',
'6월',
'7월',
'8월',
'9월',
'10월',
'11월',
'12월',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: '월', width: 80 },
{ id: 'seoul', title: '서울', width: 110, kind: 'number' },
{ id: 'busan', title: '부산', width: 110, kind: 'number' },
{ id: 'daegu', title: '대구', width: 110, kind: 'number' },
{ id: 'jeju', title: '제주', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === 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">행 (기본)</option>
<option value="column">컬럼</option>
<option value="cross" selected>십자 (행+컬럼)</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<Grid style="height: 380px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = [
'1월',
'2월',
'3월',
'4월',
'5월',
'6월',
'7월',
'8월',
'9월',
'10월',
'11월',
'12월',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: '월', width: 80 },
{ id: 'seoul', title: '서울', width: 110, kind: 'number' },
{ id: 'busan', title: '부산', width: 110, kind: 'number' },
{ id: 'daegu', title: '대구', width: 110, kind: 'number' },
{ id: 'jeju', title: '제주', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === 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">행 (기본)</option>
<option value="column">컬럼</option>
<option value="cross" selected>십자 (행+컬럼)</option>
<option value="none">칠하지 않기</option>
</select>
</div>
<mx-grid style="height: 380px" [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;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = [
'1월',
'2월',
'3월',
'4월',
'5월',
'6월',
'7월',
'8월',
'9월',
'10월',
'11월',
'12월',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: '월', width: 80 },
{ id: 'seoul', title: '서울', width: 110, kind: 'number' },
{ id: 'busan', title: '부산', width: 110, kind: 'number' },
{ id: 'daegu', title: '대구', width: 110, kind: 'number' },
{ id: 'jeju', title: '제주', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === 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">Row (default)</option>
<option value="column">Column</option>
<option value="cross" selected>Cross (row + column)</option>
<option value="none">Nothing</option>
</select>
</div>
<div id="grid" style="height: 380px"></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 months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
export const options = {
columns: [
{ id: 'month', title: 'Month', width: 80 },
{ id: 'seoul', title: 'Seoul', width: 110, kind: 'number' },
{ id: 'busan', title: 'Busan', width: 110, kind: 'number' },
{ id: 'daegu', title: 'Daegu', width: 110, kind: 'number' },
{ id: 'jeju', title: 'Jeju', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api, value) => {
const modes = ['row', 'column', 'cross', 'none'];
api.setOptions({ hover: modes.find((m) => m === 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 column on hover</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Hover range" id="mode">
<option value="row">Row (default)</option>
<option value="column">Column</option>
<option value="cross" selected>Cross (row + column)</option>
<option value="none">Nothing</option>
</select>
</div>
<div id="grid" style="height: 380px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const options = {
columns: [
{ id: 'month', title: 'Month', width: 80 },
{ id: 'seoul', title: 'Seoul', width: 110, kind: 'number' },
{ id: 'busan', title: 'Busan', width: 110, kind: 'number' },
{ id: 'daegu', title: 'Daegu', width: 110, kind: 'number' },
{ id: 'jeju', title: 'Jeju', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
const actions = {
mode: (api, value) => {
const modes = ['row', 'column', 'cross', 'none'];
api.setOptions({ hover: modes.find((m) => m === value) ?? 'row' });
},
};
options.ariaLabel = "Highlight the column 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">Row (default)</option>
<option value="column">Column</option>
<option value="cross">Cross (row + column)</option>
<option value="none">Nothing</option>
</select>
</div>
<Grid style={{ height: 380 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: 'Month', width: 80 },
{ id: 'seoul', title: 'Seoul', width: 110, kind: 'number' },
{ id: 'busan', title: 'Busan', width: 110, kind: 'number' },
{ id: 'daegu', title: 'Daegu', width: 110, kind: 'number' },
{ id: 'jeju', title: 'Jeju', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === 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">Row (default)</option>
<option value="column">Column</option>
<option value="cross" selected>Cross (row + column)</option>
<option value="none">Nothing</option>
</select>
</div>
<Grid style="height: 380px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: 'Month', width: 80 },
{ id: 'seoul', title: 'Seoul', width: 110, kind: 'number' },
{ id: 'busan', title: 'Busan', width: 110, kind: 'number' },
{ id: 'daegu', title: 'Daegu', width: 110, kind: 'number' },
{ id: 'jeju', title: 'Jeju', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === 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">Row (default)</option>
<option value="column">Column</option>
<option value="cross" selected>Cross (row + column)</option>
<option value="none">Nothing</option>
</select>
</div>
<mx-grid style="height: 380px" [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;
month: string;
seoul: number;
busan: number;
daegu: number;
jeju: number;
}
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'month', title: 'Month', width: 80 },
{ id: 'seoul', title: 'Seoul', width: 110, kind: 'number' },
{ id: 'busan', title: 'Busan', width: 110, kind: 'number' },
{ id: 'daegu', title: 'Daegu', width: 110, kind: 'number' },
{ id: 'jeju', title: 'Jeju', width: 110, kind: 'number' },
],
rows: months.map((month, i) => ({
id: i + 1,
month,
seoul: 1200 + ((i * 131) % 700),
busan: 800 + ((i * 97) % 500),
daegu: 600 + ((i * 53) % 400),
jeju: 300 + ((i * 71) % 300),
})),
rowKey: 'id',
striped: false,
hover: 'cross',
};
// hover: 'row' | 'cell' | 'column' | 'cross' | 'none'
export const actions = {
mode: (api: GridApi<Row>, value?: string) => {
const modes = ['row', 'column', 'cross', 'none'] as const;
api.setOptions({ hover: modes.find((m) => m === value) ?? 'row' });
},
};