헤더 높이를 넉넉하게, 또는 촘촘하게Make the header taller or tighter
헤더 높이 설정 하나로 헤더 한 줄의 높이를 정해요. 헤더가 두 단이면 모든 단이 같은 높이로 늘고 줄어요. 제목이 두 줄인 칸은 헤더를 높이면 잘리지 않고 다 보여요.One header height setting sets the height of a header line. With two-level headers every level grows and shrinks together. Raise it and a two-line title is no longer cut off.
코드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="height">
<option value="24">24px (촘촘하게)</option>
<option value="36" selected>36px (기본)</option>
<option value="48">48px</option>
<option value="64">64px (넉넉하게)</option>
</select>
</div>
<div id="grid" style="height: 360px"></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('height').addEventListener('change', (event) => actions.height(api, event.target.value));const teams = ['개발1팀', '개발2팀', '디자인팀', '영업팀', '운영팀', '인사팀'];
// headerHeight는 헤더 한 줄의 높이(px)예요. 헤더가 두 단이면 두 줄 모두 같은 높이로 늘고 줄어요(줄마다 다르게는 정할 수 없어요).
// 제목에 줄바꿈(\n)을 넣은 칸은 헤더를 높여야 두 줄이 다 보여요.
export const options = {
columns: [
{ id: 'team', title: '팀\n(소속)', width: 130 },
...['q1', 'q2', 'q3', 'q4'].map((id, i) => ({
id,
title: `${i + 1}분기`,
kind: 'number',
width: 110,
align: 'end',
})),
],
headerGroups: [
{ id: 'sales', title: '분기별 매출\n(단위: 만 원)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 2100 + ((i * 410) % 900),
q2: 2300 + ((i * 330) % 800),
q3: 1900 + ((i * 520) % 1100),
q4: 2600 + ((i * 270) % 700),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api, value) => api.setOptions({ headerHeight: Number(value ?? 36) }),
};<!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="height">
<option value="24">24px (촘촘하게)</option>
<option value="36" selected>36px (기본)</option>
<option value="48">48px</option>
<option value="64">64px (넉넉하게)</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const teams = ['개발1팀', '개발2팀', '디자인팀', '영업팀', '운영팀', '인사팀'];
// headerHeight는 헤더 한 줄의 높이(px)예요. 헤더가 두 단이면 두 줄 모두 같은 높이로 늘고 줄어요(줄마다 다르게는 정할 수 없어요).
// 제목에 줄바꿈(\n)을 넣은 칸은 헤더를 높여야 두 줄이 다 보여요.
const options = {
columns: [
{ id: 'team', title: '팀\n(소속)', width: 130 },
...['q1', 'q2', 'q3', 'q4'].map((id, i) => ({
id,
title: `${i + 1}분기`,
kind: 'number',
width: 110,
align: 'end',
})),
],
headerGroups: [
{ id: 'sales', title: '분기별 매출\n(단위: 만 원)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 2100 + ((i * 410) % 900),
q2: 2300 + ((i * 330) % 800),
q3: 1900 + ((i * 520) % 1100),
q4: 2600 + ((i * 270) % 700),
})),
rowKey: 'id',
headerHeight: 36,
};
const actions = {
height: (api, value) => api.setOptions({ headerHeight: Number(value ?? 36) }),
};
options.ariaLabel = "헤더 높이를 넉넉하게, 또는 촘촘하게";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('height').addEventListener('change', (event) => actions.height(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.height(api, event.target.value)}
>
<option value="24">24px (촘촘하게)</option>
<option value="36">36px (기본)</option>
<option value="48">48px</option>
<option value="64">64px (넉넉하게)</option>
</select>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['개발1팀', '개발2팀', '디자인팀', '영업팀', '운영팀', '인사팀'];
// headerHeight는 헤더 한 줄의 높이(px)예요. 헤더가 두 단이면 두 줄 모두 같은 높이로 늘고 줄어요(줄마다 다르게는 정할 수 없어요).
// 제목에 줄바꿈(\n)을 넣은 칸은 헤더를 높여야 두 줄이 다 보여요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: '팀\n(소속)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `${i + 1}분기`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: '분기별 매출\n(단위: 만 원)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 2100 + ((i * 410) % 900),
q2: 2300 + ((i * 330) % 800),
q3: 1900 + ((i * 520) % 1100),
q4: 2600 + ((i * 270) % 700),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};버튼을 누르면 이 예제의 코드가 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.height(api, ($event.target as HTMLSelectElement).value)"
>
<option value="24">24px (촘촘하게)</option>
<option value="36" selected>36px (기본)</option>
<option value="48">48px</option>
<option value="64">64px (넉넉하게)</option>
</select>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['개발1팀', '개발2팀', '디자인팀', '영업팀', '운영팀', '인사팀'];
// headerHeight는 헤더 한 줄의 높이(px)예요. 헤더가 두 단이면 두 줄 모두 같은 높이로 늘고 줄어요(줄마다 다르게는 정할 수 없어요).
// 제목에 줄바꿈(\n)을 넣은 칸은 헤더를 높여야 두 줄이 다 보여요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: '팀\n(소속)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `${i + 1}분기`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: '분기별 매출\n(단위: 만 원)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 2100 + ((i * 410) % 900),
q2: 2300 + ((i * 330) % 800),
q3: 1900 + ((i * 520) % 1100),
q4: 2600 + ((i * 270) % 700),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};버튼을 누르면 이 예제의 코드가 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.height(api, $any($event.target).value)"
>
<option value="24">24px (촘촘하게)</option>
<option value="36" selected>36px (기본)</option>
<option value="48">48px</option>
<option value="64">64px (넉넉하게)</option>
</select>
</div>
<mx-grid style="height: 360px" [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;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['개발1팀', '개발2팀', '디자인팀', '영업팀', '운영팀', '인사팀'];
// headerHeight는 헤더 한 줄의 높이(px)예요. 헤더가 두 단이면 두 줄 모두 같은 높이로 늘고 줄어요(줄마다 다르게는 정할 수 없어요).
// 제목에 줄바꿈(\n)을 넣은 칸은 헤더를 높여야 두 줄이 다 보여요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: '팀\n(소속)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `${i + 1}분기`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: '분기별 매출\n(단위: 만 원)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 2100 + ((i * 410) % 900),
q2: 2300 + ((i * 330) % 800),
q3: 1900 + ((i * 520) % 1100),
q4: 2600 + ((i * 270) % 700),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};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="Header row height" id="height">
<option value="24">24px (tight)</option>
<option value="36" selected>36px (default)</option>
<option value="48">48px</option>
<option value="64">64px (roomy)</option>
</select>
</div>
<div id="grid" style="height: 360px"></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('height').addEventListener('change', (event) => actions.height(api, event.target.value));const teams = ['Dev 1', 'Dev 2', 'Design', 'Sales', 'Ops', 'HR'];
// headerHeight is the height of one header row in px. With a two-level header both rows grow and shrink to the same height (you cannot set it per row).
// A cell whose title contains a line break (\n) needs a taller header to show both lines.
export const options = {
columns: [
{ id: 'team', title: 'Team\n(Dept.)', width: 130 },
...['q1', 'q2', 'q3', 'q4'].map((id, i) => ({
id,
title: `Q${i + 1}`,
kind: 'number',
width: 110,
align: 'end',
})),
],
headerGroups: [
{ id: 'sales', title: 'Sales by quarter\n($)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 10 * (2100 + ((i * 410) % 900)),
q2: 10 * (2300 + ((i * 330) % 800)),
q3: 10 * (1900 + ((i * 520) % 1100)),
q4: 10 * (2600 + ((i * 270) % 700)),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api, value) => api.setOptions({ headerHeight: Number(value ?? 36) }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Make the header taller or tighter</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Header row height" id="height">
<option value="24">24px (tight)</option>
<option value="36" selected>36px (default)</option>
<option value="48">48px</option>
<option value="64">64px (roomy)</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const teams = ['Dev 1', 'Dev 2', 'Design', 'Sales', 'Ops', 'HR'];
// headerHeight is the height of one header row in px. With a two-level header both rows grow and shrink to the same height (you cannot set it per row).
// A cell whose title contains a line break (\n) needs a taller header to show both lines.
const options = {
columns: [
{ id: 'team', title: 'Team\n(Dept.)', width: 130 },
...['q1', 'q2', 'q3', 'q4'].map((id, i) => ({
id,
title: `Q${i + 1}`,
kind: 'number',
width: 110,
align: 'end',
})),
],
headerGroups: [
{ id: 'sales', title: 'Sales by quarter\n($)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 10 * (2100 + ((i * 410) % 900)),
q2: 10 * (2300 + ((i * 330) % 800)),
q3: 10 * (1900 + ((i * 520) % 1100)),
q4: 10 * (2600 + ((i * 270) % 700)),
})),
rowKey: 'id',
headerHeight: 36,
};
const actions = {
height: (api, value) => api.setOptions({ headerHeight: Number(value ?? 36) }),
};
options.ariaLabel = "Make the header taller or tighter";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('height').addEventListener('change', (event) => actions.height(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="Header row height"
disabled={!api}
onChange={(event) => api && actions.height(api, event.target.value)}
>
<option value="24">24px (tight)</option>
<option value="36">36px (default)</option>
<option value="48">48px</option>
<option value="64">64px (roomy)</option>
</select>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['Dev 1', 'Dev 2', 'Design', 'Sales', 'Ops', 'HR'];
// headerHeight is the height of one header row in px. With a two-level header both rows grow and shrink to the same height (you cannot set it per row).
// A cell whose title contains a line break (\n) needs a taller header to show both lines.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: 'Team\n(Dept.)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `Q${i + 1}`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: 'Sales by quarter\n($)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 10 * (2100 + ((i * 410) % 900)),
q2: 10 * (2300 + ((i * 330) % 800)),
q3: 10 * (1900 + ((i * 520) % 1100)),
q4: 10 * (2600 + ((i * 270) % 700)),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};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="Header row height"
:disabled="!api"
@change="api && actions.height(api, ($event.target as HTMLSelectElement).value)"
>
<option value="24">24px (tight)</option>
<option value="36" selected>36px (default)</option>
<option value="48">48px</option>
<option value="64">64px (roomy)</option>
</select>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['Dev 1', 'Dev 2', 'Design', 'Sales', 'Ops', 'HR'];
// headerHeight is the height of one header row in px. With a two-level header both rows grow and shrink to the same height (you cannot set it per row).
// A cell whose title contains a line break (\n) needs a taller header to show both lines.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: 'Team\n(Dept.)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `Q${i + 1}`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: 'Sales by quarter\n($)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 10 * (2100 + ((i * 410) % 900)),
q2: 10 * (2300 + ((i * 330) % 800)),
q3: 10 * (1900 + ((i * 520) % 1100)),
q4: 10 * (2600 + ((i * 270) % 700)),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};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="Header row height"
[disabled]="!api"
(change)="api && actions.height(api, $any($event.target).value)"
>
<option value="24">24px (tight)</option>
<option value="36" selected>36px (default)</option>
<option value="48">48px</option>
<option value="64">64px (roomy)</option>
</select>
</div>
<mx-grid style="height: 360px" [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;
team: string;
q1: number;
q2: number;
q3: number;
q4: number;
}
const teams = ['Dev 1', 'Dev 2', 'Design', 'Sales', 'Ops', 'HR'];
// headerHeight is the height of one header row in px. With a two-level header both rows grow and shrink to the same height (you cannot set it per row).
// A cell whose title contains a line break (\n) needs a taller header to show both lines.
export const options: GridOptions<Row> = {
columns: [
{ id: 'team', title: 'Team\n(Dept.)', width: 130 },
...(['q1', 'q2', 'q3', 'q4'] as const).map((id, i) => ({
id,
title: `Q${i + 1}`,
kind: 'number' as const,
width: 110,
align: 'end' as const,
})),
],
headerGroups: [
{ id: 'sales', title: 'Sales by quarter\n($)', children: ['q1', 'q2', 'q3', 'q4'] },
],
rows: teams.map((team, i) => ({
id: i + 1,
team,
q1: 10 * (2100 + ((i * 410) % 900)),
q2: 10 * (2300 + ((i * 330) % 800)),
q3: 10 * (1900 + ((i * 520) % 1100)),
q4: 10 * (2600 + ((i * 270) % 700)),
})),
rowKey: 'id',
headerHeight: 36,
};
export const actions = {
height: (api: GridApi<Row>, value?: string) =>
api.setOptions({ headerHeight: Number(value ?? 36) }),
};