머리글 제목 바로 고치기Edit a header title in place
headerRendererParams: { editable: true }를 주면 제목을 두 번 눌러 그 자리에서 고쳐요. Enter나 포커스를 잃으면 확정되어 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. Esc는 취소, 빈 글자와 같은 글자는 바뀌지 않으며 한글 조합 중 Enter·Esc는 무시해요.With headerRendererParams: { editable: true } a double click on the title edits it in place. Enter or losing focus commits it: updateColumn(id, { title }) is called and a headerRenamed event arrives. Esc cancels, empty or same text changes nothing, and Enter and Esc during an IME composition are ignored.
코드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 id="grid" style="height: 200px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);const rows = [
{ id: 1, task: '로그인 화면 수정', owner: '김하늘', done: false },
{ id: 2, task: '결제 흐름 검토', owner: '이도윤', done: true },
{ id: 3, task: '새 아이콘 세트', owner: '박서연', done: false },
{ id: 4, task: '배포 점검', owner: '최지우', done: false },
];
// headerRendererParams: { editable: true }: 제목을 두 번 누르면 그 자리에서 고쳐요. Enter 확정, Esc 취소, 한글 조합 중 Enter는 무시.
// 확정하면 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. 글자가 비었거나 같으면 바뀌지 않아요.
export const options = {
columns: [
{ id: 'task', title: '작업', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: '담당', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: '완료', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api, log) {
log({
ko: '"작업"이나 "담당" 머리글의 제목을 두 번 눌러 고쳐 보세요. "완료"는 고칠 수 없어요.',
en: 'Double-click the Task or Owner header title to edit it. Done cannot be renamed.',
});
return api.on('headerRenamed', (e) => log({
ko: `headerRenamed: ${e.columnId} → "${e.title}"`,
en: `headerRenamed: ${e.columnId} → "${e.title}"`,
}));
}<!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 id="grid" style="height: 200px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = [
{ id: 1, task: '로그인 화면 수정', owner: '김하늘', done: false },
{ id: 2, task: '결제 흐름 검토', owner: '이도윤', done: true },
{ id: 3, task: '새 아이콘 세트', owner: '박서연', done: false },
{ id: 4, task: '배포 점검', owner: '최지우', done: false },
];
// headerRendererParams: { editable: true }: 제목을 두 번 누르면 그 자리에서 고쳐요. Enter 확정, Esc 취소, 한글 조합 중 Enter는 무시.
// 확정하면 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. 글자가 비었거나 같으면 바뀌지 않아요.
const options = {
columns: [
{ id: 'task', title: '작업', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: '담당', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: '완료', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
function setup(api, log) {
log({
ko: '"작업"이나 "담당" 머리글의 제목을 두 번 눌러 고쳐 보세요. "완료"는 고칠 수 없어요.',
en: 'Double-click the Task or Owner header title to edit it. Done cannot be renamed.',
});
return api.on('headerRenamed', (e) => log({
ko: `headerRenamed: ${e.columnId} → "${e.title}"`,
en: `headerRenamed: ${e.columnId} → "${e.title}"`,
}));
}
options.ariaLabel = "머리글 제목 바로 고치기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<Grid style={{ height: 200 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: '로그인 화면 수정', owner: '김하늘', done: false },
{ id: 2, task: '결제 흐름 검토', owner: '이도윤', done: true },
{ id: 3, task: '새 아이콘 세트', owner: '박서연', done: false },
{ id: 4, task: '배포 점검', owner: '최지우', done: false },
];
// headerRendererParams: { editable: true }: 제목을 두 번 누르면 그 자리에서 고쳐요. Enter 확정, Esc 취소, 한글 조합 중 Enter는 무시.
// 확정하면 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. 글자가 비었거나 같으면 바뀌지 않아요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: '담당', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: '완료', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '"작업"이나 "담당" 머리글의 제목을 두 번 눌러 고쳐 보세요. "완료"는 고칠 수 없어요.',
en: 'Double-click the Task or Owner header title to edit it. Done cannot be renamed.',
});
return api.on('headerRenamed', (e) =>
log({
ko: `headerRenamed: ${e.columnId} → "${e.title}"`,
en: `headerRenamed: ${e.columnId} → "${e.title}"`,
}),
);
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<Grid style="height: 200px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: '로그인 화면 수정', owner: '김하늘', done: false },
{ id: 2, task: '결제 흐름 검토', owner: '이도윤', done: true },
{ id: 3, task: '새 아이콘 세트', owner: '박서연', done: false },
{ id: 4, task: '배포 점검', owner: '최지우', done: false },
];
// headerRendererParams: { editable: true }: 제목을 두 번 누르면 그 자리에서 고쳐요. Enter 확정, Esc 취소, 한글 조합 중 Enter는 무시.
// 확정하면 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. 글자가 비었거나 같으면 바뀌지 않아요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: '담당', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: '완료', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '"작업"이나 "담당" 머리글의 제목을 두 번 눌러 고쳐 보세요. "완료"는 고칠 수 없어요.',
en: 'Double-click the Task or Owner header title to edit it. Done cannot be renamed.',
});
return api.on('headerRenamed', (e) =>
log({
ko: `headerRenamed: ${e.columnId} → "${e.title}"`,
en: `headerRenamed: ${e.columnId} → "${e.title}"`,
}),
);
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 200px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: '로그인 화면 수정', owner: '김하늘', done: false },
{ id: 2, task: '결제 흐름 검토', owner: '이도윤', done: true },
{ id: 3, task: '새 아이콘 세트', owner: '박서연', done: false },
{ id: 4, task: '배포 점검', owner: '최지우', done: false },
];
// headerRendererParams: { editable: true }: 제목을 두 번 누르면 그 자리에서 고쳐요. Enter 확정, Esc 취소, 한글 조합 중 Enter는 무시.
// 확정하면 updateColumn(id, { title })가 불리고 headerRenamed 이벤트가 와요. 글자가 비었거나 같으면 바뀌지 않아요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '작업', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: '담당', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: '완료', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '"작업"이나 "담당" 머리글의 제목을 두 번 눌러 고쳐 보세요. "완료"는 고칠 수 없어요.',
en: 'Double-click the Task or Owner header title to edit it. Done cannot be renamed.',
});
return api.on('headerRenamed', (e) =>
log({
ko: `headerRenamed: ${e.columnId} → "${e.title}"`,
en: `headerRenamed: ${e.columnId} → "${e.title}"`,
}),
);
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div id="grid" style="height: 200px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);const rows = [
{ id: 1, task: 'Fix login screen', owner: 'Liam Carter', done: false },
{ id: 2, task: 'Review payment flow', owner: 'Ethan Clark', done: true },
{ id: 3, task: 'New icon set', owner: 'Emma Stone', done: false },
{ id: 4, task: 'Deployment check', owner: 'Olivia Reed', done: false },
];
// headerRendererParams: { editable: true }: double-click the title to edit it in place. Enter confirms, Esc cancels, Enter during IME composition is ignored.
// On confirm, updateColumn(id, { title }) is called and a headerRenamed event arrives. An empty or unchanged text changes nothing.
export const options = {
columns: [
{ id: 'task', title: 'Task', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: 'Owner', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: 'Done', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api, log) {
log('Double-click the Task or Owner header title to edit it. Done cannot be renamed.');
return api.on('headerRenamed', (e) => log(`headerRenamed: ${e.columnId} → "${e.title}"`));
}<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Edit a header title in place</title>
</head>
<body>
<div id="grid" style="height: 200px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = [
{ id: 1, task: 'Fix login screen', owner: 'Liam Carter', done: false },
{ id: 2, task: 'Review payment flow', owner: 'Ethan Clark', done: true },
{ id: 3, task: 'New icon set', owner: 'Emma Stone', done: false },
{ id: 4, task: 'Deployment check', owner: 'Olivia Reed', done: false },
];
// headerRendererParams: { editable: true }: double-click the title to edit it in place. Enter confirms, Esc cancels, Enter during IME composition is ignored.
// On confirm, updateColumn(id, { title }) is called and a headerRenamed event arrives. An empty or unchanged text changes nothing.
const options = {
columns: [
{ id: 'task', title: 'Task', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: 'Owner', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: 'Done', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
function setup(api, log) {
log('Double-click the Task or Owner header title to edit it. Done cannot be renamed.');
return api.on('headerRenamed', (e) => log(`headerRenamed: ${e.columnId} → "${e.title}"`));
}
options.ariaLabel = "Edit a header title in place";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<Grid style={{ height: 200 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: 'Fix login screen', owner: 'Liam Carter', done: false },
{ id: 2, task: 'Review payment flow', owner: 'Ethan Clark', done: true },
{ id: 3, task: 'New icon set', owner: 'Emma Stone', done: false },
{ id: 4, task: 'Deployment check', owner: 'Olivia Reed', done: false },
];
// headerRendererParams: { editable: true }: double-click the title to edit it in place. Enter confirms, Esc cancels, Enter during IME composition is ignored.
// On confirm, updateColumn(id, { title }) is called and a headerRenamed event arrives. An empty or unchanged text changes nothing.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: 'Owner', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: 'Done', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click the Task or Owner header title to edit it. Done cannot be renamed.');
return api.on('headerRenamed', (e) => log(`headerRenamed: ${e.columnId} → "${e.title}"`));
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<Grid style="height: 200px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: 'Fix login screen', owner: 'Liam Carter', done: false },
{ id: 2, task: 'Review payment flow', owner: 'Ethan Clark', done: true },
{ id: 3, task: 'New icon set', owner: 'Emma Stone', done: false },
{ id: 4, task: 'Deployment check', owner: 'Olivia Reed', done: false },
];
// headerRendererParams: { editable: true }: double-click the title to edit it in place. Enter confirms, Esc cancels, Enter during IME composition is ignored.
// On confirm, updateColumn(id, { title }) is called and a headerRenamed event arrives. An empty or unchanged text changes nothing.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: 'Owner', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: 'Done', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click the Task or Owner header title to edit it. Done cannot be renamed.');
return api.on('headerRenamed', (e) => log(`headerRenamed: ${e.columnId} → "${e.title}"`));
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 200px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
done: boolean;
}
const rows: Row[] = [
{ id: 1, task: 'Fix login screen', owner: 'Liam Carter', done: false },
{ id: 2, task: 'Review payment flow', owner: 'Ethan Clark', done: true },
{ id: 3, task: 'New icon set', owner: 'Emma Stone', done: false },
{ id: 4, task: 'Deployment check', owner: 'Olivia Reed', done: false },
];
// headerRendererParams: { editable: true }: double-click the title to edit it in place. Enter confirms, Esc cancels, Enter during IME composition is ignored.
// On confirm, updateColumn(id, { title }) is called and a headerRenamed event arrives. An empty or unchanged text changes nothing.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 170, headerRendererParams: { editable: true } },
{ id: 'owner', title: 'Owner', width: 110, headerRendererParams: { editable: true } },
{ id: 'done', title: 'Done', kind: 'boolean', width: 90 },
],
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Double-click the Task or Owner header title to edit it. Done cannot be renamed.');
return api.on('headerRenamed', (e) => log(`headerRenamed: ${e.columnId} → "${e.title}"`));
}