본문으로 건너뛰기Skip to content
예제 첫화면Examples home

머리글 제목 바로 고치기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.

입문Beginner
직접 써 보기Live preview머리글 제목 바로 고치기Edit a header title in place

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<div id="app">
  <div id="grid" style="height: 200px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
example.js
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}"`,
  }));
}

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div id="grid" style="height: 200px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
example.js
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}"`));
}