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

줄을 두 번 눌러 옆 폼에서 고치기Edit a row in a side form (double-click)

rowEditPanel: true면 줄을 두 번 누를 때 옆에 폼이 열려요. 칸 종류에 맞는 편집기로 여러 칸을 고치고 저장하면 한 번에 반영되고, 되돌리기도 한 번이에요.With rowEditPanel: true a double-click on a row opens a form beside the grid. Edit several fields with the editor of each column kind; Save applies them at once and undo is a single step.

입문Beginner
직접 써 보기Live preview줄을 두 번 눌러 옆 폼에서 고치기Edit a row in a side form (double-click)

코드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 class="toolbar">
    <button type="button" id="openFirst">첫 줄 열기</button>
    <button type="button" id="undo">되돌리기</button>
  </div>
  <div id="grid" style="height: 330px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('openFirst').addEventListener('click', () => actions.openFirst(api));
document.getElementById('undo').addEventListener('click', () => actions.undo(api));
example.js
const rows = [
  {
    id: 1,
    name: '김서연',
    team: '개발',
    hours: 32,
    joined: '2024-03-04',
    active: true,
    memo: '신규 입사자 멘토',
  },
  {
    id: 2,
    name: '이준호',
    team: '디자인',
    hours: 40,
    joined: '2023-08-21',
    active: true,
    memo: '',
  },
  {
    id: 3,
    name: '박민지',
    team: '기획',
    hours: 24,
    joined: '2022-11-07',
    active: false,
    memo: '육아 휴직 중',
  },
  { id: 4, name: '최도윤', team: '개발', hours: 36, joined: '2021-05-17', active: true, memo: '' },
  {
    id: 5,
    name: '정하은',
    team: '영업',
    hours: 28,
    joined: '2025-01-13',
    active: true,
    memo: '수습 기간',
  },
];
// rowEditPanel: true면 줄을 두 번 누를 때 칸 편집 대신 옆 폼이 열려요. 폼은 칸 종류에 맞는 편집기(글자·선택·숫자·날짜·체크·여러 줄)로 만들어져요.
// 저장하면 고친 칸이 한 번에 반영되고 되돌리기도 한 번이에요.
export const options = {
  rowEditPanel: true,
  columns: [
    {
      id: 'name',
      title: '이름',
      width: 130,
      editable: true,
      validation: { required: true, maxLength: 20 },
    },
    {
      id: 'team',
      title: '팀',
      kind: 'select',
      width: 100,
      editable: true,
      editorOptions: ['개발', '디자인', '기획', '영업'].map((value) => ({ value })),
    },
    {
      id: 'hours',
      title: '주간 시간',
      kind: 'number',
      width: 110,
      align: 'end',
      editable: true,
      validation: { min: 0, max: 60 },
    },
    { id: 'joined', title: '입사일', kind: 'date', width: 120, editable: true },
    { id: 'active', title: '재직', kind: 'boolean', width: 80, editable: true },
    { id: 'memo', title: '메모', width: 180, editable: true, cellEditor: 'textarea' },
  ],
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log({
    ko: '줄을 두 번 누르면 옆에 폼이 열려요. 여러 칸을 고치고 Ctrl+Enter로 저장해 보세요.',
    en: 'Double-click a row to open the form beside the grid. Edit a few fields and press Ctrl+Enter to save.',
  });
  const offs = [
    api.on('rowPanelOpened', (e) => log({ ko: `폼 열림: ${e.rowKey}번 줄`, en: `Form opened: row ${e.rowKey}` })),
    api.on('editCommitted', (e) => log({
      ko: `· ${e.columnId}: ${String(e.oldValue)} → ${String(e.newValue)}`,
      en: `· ${e.columnId}: ${String(e.oldValue)} → ${String(e.newValue)}`,
    })),
    api.on('rowPanelSaved', (e) => log({
      ko: `✓ 저장: ${Object.keys(e.changes).length}칸을 한 번에 반영했어요`,
      en: `✓ Saved: ${Object.keys(e.changes).length} fields applied at once`,
    })),
    api.on('rowPanelClosed', (e) => log({ ko: `폼 닫힘 (${e.reason})`, en: `Form closed (${e.reason})` })),
  ];
  return () => offs.forEach((off) => off());
}
export const actions = {
  openFirst: (api) => api.openRowPanel(1),
  undo: (api) => api.undo(),
};

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 class="toolbar">
    <button type="button" id="openFirst">Open first row</button>
    <button type="button" id="undo">Undo</button>
  </div>
  <div id="grid" style="height: 330px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('openFirst').addEventListener('click', () => actions.openFirst(api));
document.getElementById('undo').addEventListener('click', () => actions.undo(api));
example.js
const rows = [
  {
    id: 1,
    name: 'Liam Carter',
    team: 'Dev',
    hours: 32,
    joined: '2024-03-04',
    active: true,
    memo: 'Mentor for new hires',
  },
  {
    id: 2,
    name: 'Emma Stone',
    team: 'Design',
    hours: 40,
    joined: '2023-08-21',
    active: true,
    memo: '',
  },
  {
    id: 3,
    name: 'Noah Kim',
    team: 'Planning',
    hours: 24,
    joined: '2022-11-07',
    active: false,
    memo: 'On parental leave',
  },
  {
    id: 4,
    name: 'Olivia Reed',
    team: 'Dev',
    hours: 36,
    joined: '2021-05-17',
    active: true,
    memo: '',
  },
  {
    id: 5,
    name: 'Ava Brooks',
    team: 'Sales',
    hours: 28,
    joined: '2025-01-13',
    active: true,
    memo: 'Probation period',
  },
];
// With rowEditPanel: true a double-click on a row opens the form beside the grid instead of editing a cell. The form uses the editor of each column kind
// (text, select, number, date, checkbox, multi-line). Save applies the changed fields at once and undo is one step.
export const options = {
  rowEditPanel: true,
  columns: [
    {
      id: 'name',
      title: 'Name',
      width: 130,
      editable: true,
      validation: { required: true, maxLength: 20 },
    },
    {
      id: 'team',
      title: 'Team',
      kind: 'select',
      width: 100,
      editable: true,
      editorOptions: ['Dev', 'Design', 'Planning', 'Sales'].map((value) => ({ value })),
    },
    {
      id: 'hours',
      title: 'Weekly hours',
      kind: 'number',
      width: 140,
      align: 'end',
      editable: true,
      validation: { min: 0, max: 60 },
    },
    { id: 'joined', title: 'Joined', kind: 'date', width: 120, editable: true },
    { id: 'active', title: 'Active', kind: 'boolean', width: 80, editable: true },
    { id: 'memo', title: 'Memo', width: 180, editable: true, cellEditor: 'textarea' },
  ],
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log('Double-click a row to open the form beside the grid. Edit a few fields and press Ctrl+Enter to save.');
  const offs = [
    api.on('rowPanelOpened', (e) => log(`Form opened: row ${e.rowKey}`)),
    api.on('editCommitted', (e) => log(`· ${e.columnId}: ${String(e.oldValue)} → ${String(e.newValue)}`)),
    api.on('rowPanelSaved', (e) => log(`✓ Saved: ${Object.keys(e.changes).length} fields applied at once`)),
    api.on('rowPanelClosed', (e) => log(`Form closed (${e.reason})`)),
  ];
  return () => offs.forEach((off) => off());
}
export const actions = {
  openFirst: (api) => api.openRowPanel(1),
  undo: (api) => api.undo(),
};