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

RTL에서 고정 컬럼과 끌기 쓰기Pinned columns and dragging in RTL

direction: 'rtl'에서 행 끌기 손잡이, 셀 범위 끌기, 채우기 핸들, 시작 쪽 고정 컬럼이 오른쪽부터 같은 방식으로 동작해요.With direction: 'rtl' the row drag handle, cell range dragging, the fill handle and the start-side pinned column work the same way, starting from the right.

심화Advanced
직접 써 보기Live previewRTL에서 고정 컬럼과 끌기 쓰기Pinned columns and dragging in RTL

코드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="select">담당 2칸 선택</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('select').addEventListener('click', () => actions.select(api));
example.js
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
  id: i + 1,
  task,
  owner: owners[i % 4],
  note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
export const options = {
  columns: [
    { id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
    { id: 'owner', title: 'אחראי', width: 120, editable: true },
    { id: 'note', title: 'הערה', width: 180, editable: true },
  ],
  direction: 'rtl',
  selection: 'multiple',
  cellSelection: 'multiple',
  rowDrag: true,
  cellDrag: true,
  cellFill: true,
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log({
    ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
    en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
  });
  const offs = [
    api.on('rowDropped', (e) => log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` })),
    api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
  ];
  return () => offs.forEach((off) => off());
}
export const actions = {
  select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};

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="select">Select 2 owner cells</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('select').addEventListener('click', () => actions.select(api));
example.js
// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
  id: i + 1,
  task,
  owner: owners[i % 4],
  note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
export const options = {
  columns: [
    { id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
    { id: 'owner', title: 'אחראי', width: 120, editable: true },
    { id: 'note', title: 'הערה', width: 180, editable: true },
  ],
  direction: 'rtl',
  selection: 'multiple',
  cellSelection: 'multiple',
  rowDrag: true,
  cellDrag: true,
  cellFill: true,
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log('Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.');
  const offs = [
    api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
    api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
  ];
  return () => offs.forEach((off) => off());
}
export const actions = {
  select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};